I'm using Voyager Laravel to build my app, but I'm having some issues regarding the form fields, in my Bread column of "transmission" I have included in the JSON form this:
column transmission:
{
"options": {
"option1": "Automática",
"option2": "Manual"
}
}
In the admin is displaying well the information, the problem is when I call it in the frontend for example:
$car->transmission -> outputs -> "option1"
I'm trying to find in the documentation regarding calling only the text/label of the option1 that is correct, but no information I'm finding.
Anybody the uses Voyager had the same issue?
Not at all. That's up to you.
But you can use the key (option1, option2, ...) and rename it to something you can use in your frontend.
Related
I can't figure out how to set up the links. I have created a collection. I need an creator to be automatically specified in that record when adding a record to the collection. How do I do that?
I've faced this problem...
I found the solution in the documentation:
need to add
"populateCreatorFields": true
in the file (strapi v3) /api/your-type-name/models/your-type-name.settings.json
in options object
like:
...
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true,
"populateCreatorFields": true
},
...
More information can be found at strapi documentation
Strapi does not support it by default. As mentioned in this form you can achieve it by editing the strapi's controller. But I will not recommend you to edit the strapi controller at all. Please avoid it.
There is a simple and better solution to this. You can achieve this by creating one to one relationship. Create an author table/collection. Make one to one relationship with your other collection. You can make it a required option as well. So whenever someone creates an entry they have to select an author from your already created collection of authors.
And now you can get relation in your API and use it wherever you want to.
As stated in my comment, Strapi (tested on v3) comes with a created by field. To ascertain the claim, the following steps can be followed;
Create a new content type. Here I am setting only one field, called test
Add an entry for that content type. Notice the last update and by field on the right.
Save and open the entry. The last update and by fields have been automatically populated.
I found the way to add an admin guard.
But there are no documentation to customize the following functionality:
Auth::guard('admin')->attempt()
Auth::guard('admin')->user()
Auth::guard('admin')->check()
middleware('auth:admin')
I need to check an additional field of admin table to check if the admin can be logged in.
In Auth::guard('admin')->attempt(), I want to use SQL like this:
Admin::where('login_id', $request->input('login_id'))
->where('password', md5($request->input('password')))
->where('additional_field', [additional condition]);
By Auth::guard('admin')->user(), I want to get the result of SQL like this:
Admin::where('id', Auth::guard('admin')->id())
->where('additional_field', [additional condition]);
And both Auth::guard('admin')->check() and middleware('auth:admin') also should consider the additional condition in the code above.
Is there a way to customize them?
And, are there any other functionalities of Laravel's auth which I have to customize to satisfy the requirement of the additional condition above?
I'm using Laravel 8.
IF your additional stuff are some input like login_id and password
maybe this should work.
$cradentials= $request->only('email','password','additional stuff');
if( Auth::guard('admin')->attempt($cradentials) ){
//stuff here
}
Although the official documentation of the country field in AlpacaJS states that "The names of the countries are read from the I18N bundle for the current locale," I can't make the translation work.
I have tried to set the locale using the following two ways described on their internalization documentation without success:
$.alpaca.setDefaultLocale('pt_BR');
"view": {"locale": 'pt_BR'}
In the first case, I set it up while loading all "webapp" configurations while the second is part of the form configuration and should be set when alpaca builds the form. In both cases, all the other functionalities work, except the translation of the country names.
What am I missing?
Sadly they didn't do it, they put only common validation and date messages in the locale bundles and they didn't translate the country field values!
You did it well setting the view locale though, your code works normally except in locale files you will not find any translation for country names so alpaca do like a fallback to base locale file... so unfortunately you should do it yourself by extending the country field values in the view like the following:
"messages": {
"es_ES": {
"countries": {
"tun": "TunÃsia"
...
}
}
}
And you should complete all the list or you will get a country field with only the values you put in the previous view code
here's a fiddle for this.
is it possible to remove zip/postal code field depending on country chosen in the address section of the checkout page in Magento?
e.g. when a user chooses 'Ireland' the field disappears on the fly.
thanks
Dave
In the admin panel there is an option to make zip code optional for specific countries:
System-> Configuration -> General -> Countries Options -> "Postal Code is Optional for the following countries"
Select your specific countries which you want to make optional.
If this isn't enough with a some basic modification you should be able to make the field invisible as well.
In your theme (don't modify the existing themes), copy js/opcheckout.js and modify that.
Add your observer to the zipcode fields. The best is to hide the zipcode, as the client-side validation won't fire then.
If you would like some code to get you started, I can post that in an edit.
Magento hasn't anything built-in yet. You have to wrote some javascript to do that and, of course, control this flow into Magento Core classes.
on Magento 1.7.0.2
first you have to remove 'required-entry' on zipcode field (you can use jquery to remove class)
then
go to Mage_Checkout_OnepageController
on saveBillingAction() method
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
$result = array() // clear error message;
and then on saveShippingAction() method
$result = $this->getOnepage()->saveShipping($data, $customerAddressId);
$result = array() // clear error message;
hope works!!
I am developing an online store for my customer and, we only have one website in our Magento setup.
In the admin panel when I go to Add a customer screen, in the "Associate to Website" field I see "Admin" selected by default. I would like to have my website there by default.
I think one possible way would be to write some code in:
Mage_Adminhtml_Block_Customer_Edit_Tab_Account::initForm
The cleanest way to do this is the just set the default value in your database. This will require no code changes at all.
UPDATE eav_attribute
SET default_value = 1
WHERE attribute_code = 'website_id'
The sample MySQL statement above sets your default website_id to 1.
Or You can simply edit array in:
Mage_Customer_Model_Customer_Attribute_Source_Website::getAllOptions()
I took the hint from Lrrr's answer and populated the drop-down with only user added websites, that is "Please Select" and "Admin" are no more available as options there by adding the following line:
$form->getElement('website_id')->setValues(Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm());
at the end of this function:
Mage_Adminhtml_Block_Customer_Edit_Tab_Account::initForm
The ideal way would be of course to override the above function in one's own module, but in our case overriding the above class creates conflict for another extension that we have installed, so I took this way round.