-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
bugVerified bug by the Nova teamVerified bug by the Nova team
Description
- Laravel Version: 9.22.1
- Nova Version: 4.12.13
- PHP Version: 8.1
Description:
When you have 2 different fields with the same name, the dependsOn is experiencing the following issues
- Field shows at the same time with the same label, help text etc (Experienced when using Number and Text together)
- Required validation rule is ignored even if they are set on 1 of the fields (Experienced with Number and Text together, and with Number and a custom field together)
Detailed steps to reproduce the issue on a fresh Nova installation:
Select::make('Field Type')
->options([
'text' => 'Text',
'number' => 'Number',
])
->onlyOnForms()
->displayUsingLabels(),
Number::make('Number', 'field_value')
->help('Number test')
->onlyOnForms()
->dependsOn(
['field_type'],
function (Number $field, NovaRequest $request, FormData $formData) {
if ($formData->field_type == 'number') {
$field
->show()
->rules('required');
} else {
$field
->hide();
}
}
),
Text::make('Text', 'field_value')
->help('Text test')
->onlyOnForms()
->dependsOn(
['field_type'],
function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData->field_type == 'text') {
$field
->show()
->rules('required');
} else {
$field
->hide();
}
}
),
Metadata
Metadata
Assignees
Labels
bugVerified bug by the Nova teamVerified bug by the Nova team