dependsOn issue for multiple fields #4062
-
Description:In the latest release I thought the "dependsOn" issue would be fixed. I have one field -> product -> where I want to select the product_name. And based on the product selected I have fields that will have different ad size options. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
dependson-example.mov |
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
-
You should declare Select::make('AdSize', 'adsize_label')->options([])
->dependsOn('product_name', function ($field, $request, $formData) {
if ($formData->product_name === 'A') {
$field->options(/* ... */)->show();
} elseif ($formData->product_name === 'B') {
$field->options(/* ... */)->show();
} else {
$field->hide();
}
}), |
Beta Was this translation helpful? Give feedback.
You should declare
adsize_label
only once and use multiple if else to setshow()
andoptions()
.