Closed preliot closed 5 years ago
AjaxSelect::make('Client', 'client_id')->onlyOnForms(),
BelongsTo::make('Client')->exceptOnForms(),
@dillingham Was stuck and it works now. Thanks!
My issue was that a belongsTo field needs the method on the model as a second argument to get the distributor.
\Laravel\Nova\Fields\BelongsTo::make('Distributor name', 'distributor', DistributorResource::class)
And AjaxSelect needs the attribute on the model:
return AjaxSelect::make('Client name', 'client_id') ->get(config('nova.path') . '/orglevel/distributors/{distributor}/clients') ->parent('distributor') ->rules('required');
For anyone else: Also note that the attribute in parent('attribute') must be identical to the attribute in get(config('nova.path') . '/orglevel/distributors/{attribute}/client))
When i try to save a resource, it tries to save the wrong attribute name. How do i make a difference between the method client() that gets the attribute and client_id that needs to be saved?
In this example 'client' is a method on a orgizational level model. When saving this it should be client_id instead of client.