-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
- Laravel Version: 9.x
- Nova Version: 4.21.x
- PHP Version: 8.1
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 ->options(Product::where('client_id', $formData->client_id)), but then I'd lose out on the inline creation modal, as well as all the benefits of BelongsTo.
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();
}
}
),
];
}Metadata
Metadata
Assignees
Labels
No labels