BelongsTo doesn't filter BelongsTo in dependsOn() #5357
Answered
by
crynobone
LorenzoSapora
asked this question in
Q&A
-
When using A BelongsTo field, the second field doesn't appear to be filtering by the original. Normally I'd just replace the second BelongsTo (product) with a select, with Am I missing something from the below? public function fields(NovaRequest $request): Array
{
return [
BelongsTo::make('Client', 'client', 'App\Nova\Client')
->showCreateRelationButton()
->modalSize('FULL')
->nullable()
->withoutTrashed()
->searchable(),
BelongsTo::make('Product', 'product', 'App\Nova\Product')
->hide()
->dependsOn(
['client'],
function (BelongsTo $field, NovaRequest $request, FormData $formData) {
if ($formData->client) {
$field
->show()
->showCreateRelationButton()
->modalSize('full')
->nullable()
->withoutTrashed()
->searchable();
}
}
),
];
} |
Beta Was this translation helpful? Give feedback.
Answered by
crynobone
Feb 27, 2023
Replies: 1 comment
-
You can refer to the documentation: https://nova.laravel.com/docs/4.0/resources/relationships.html#relatable-query-filtering |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
LorenzoSapora
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can refer to the documentation: https://nova.laravel.com/docs/4.0/resources/relationships.html#relatable-query-filtering