Closed CodeWithDennis closed 1 year ago
Is it not compatible? That's too bad. I haven't even looked at dependsOn
yet and assumed that any field would work as long as you stick to the docs.
Of course I will have a look at it.
Hi, i've added a small clip https://user-images.githubusercontent.com/23448484/235164981-eaea046d-f893-4d9a-93ea-5726721d0f72.mov
Would appreciate it!
There is really a DependentFormField
mixin wich must used.
Good, now that I know this, I can think of it right from the beginning when I create a field.
The dependsOn
method is available as of the current release.
Hello. DependsOn generally works well. But when used in conjunction with NovaJson, it doesn't work. So if a field DependsOn a Radio field, the Radio field only sends the first option as the value. Example below:
JSON::make('Wrapper', 'wrapper', [
Radio::make('Alpha', 'alpha')->options([
'yes' => 'Yes',
'no' => 'No'
])
->default('no'),
Radio::make('Beta', 'beta')->options([
'yes' => 'Yes',
'no' => 'No'
])
->hide()
->rules('required_if:alpha,yes')
->dependsOn('wrapper->alpha', function (Radio $field, NovaRequest $request, FormData $data) {
if($data['wrapper->alpha'] == 'yes')
$field->show();
}),
])
In this case, "alpha" will always return the value "yes", irrespective of the selection in the form.
Cheers
Sorry. The system NVMe failed on my laptop. I'll take a look at it during the week.
It seems like this field is not compatible with
dependsOn
. https://nova.laravel.com/docs/4.0/resources/fields.html#dependent-fieldsIs it possible to make this compatible?