Open Epizefiri opened 1 year ago
I'm having a similar issue, I have two Selects (country and city) they work perfectly fine... If outside the Flexible field. If inside the Flexible only the country works, as soon as I select a country the City Select literally disappears.
Has anyone being able to fix this?
This works:
Select::make('Country', 'country')->searchable()
->options(WorldCountry::orderBy('name')->get()->pluck('name', 'name'))
->rules('required'),
Select::make('City', 'city')
->dependsOn(
['country'],
function (Select $field, NovaRequest $request, FormData $formData) {
$country = WorldCountry::getByName($formData->country);
if ($country){
$field->options($country->cities()->orderBy('name')->pluck('name'));
}
}
)->searchable()
This does not:
Flexible::make('Locations', 'location')
->button('Add location')
->addLayout('Location', 'location', [
Select::make('Country', 'country')->searchable()
->options(WorldCountry::orderBy('name')->get()->pluck('name', 'name'))
->rules('required'),
Select::make('City', 'city')
->dependsOn(
['country'],
function (Select $field, NovaRequest $request, FormData $formData) {
$country = WorldCountry::getByName($formData->country);
if ($country){
$field->options($country->cities()->orderBy('name')->pluck('name'));
}
}
)->searchable()
])->rules('required')
EDIT - SOLUTION
This solves the issue, is a fork so should be removed as soon as the support is added: https://github.com/formfeed-uk/nova-flexible-content
Hello there, I've several locations by a Flexible field, when I save a location I get through an observer some "memberships". I would like to use this memberships as options for a Select field. How do I pass the options to the field?