Closed lvdhoorn closed 5 years ago
Is there a way to set the default value? withMeta() doesn't exist: https://github.com/orlyapps/nova-belongsto-depend/blob/master/src/NovaBelongsToDepend.php
Any ideas? It works great for me on new records or changing data, however I can't see how to select the proper value if it is already assigned.
I worked out my issues. Sorry for the post.
Hello,
Default value works like this. Not very ideal and confusion but it works.
NovaBelongsToDepend::make('Unternehmen', 'company', \App\Nova\Company::class) ->withMeta(['value' => $this->company ?? \Auth::user()->company, 'valueKey' => $this->company->id ?? \Auth::user()->company->id]) ->options(\App\Company::all()) ->onlyOnForms() ->rules('required'),
@orlyapps Thank you! This works but when I use this within Conditional Container (https://github.com/dcasia/conditional-container) it comes with the default value but the dependent field doesn't populate(Its hidden by default, I need to change a value in another field to make it visible). I need to select another value then reselect the default value to trigger the dependent population. Any ideas?
When you trying to set a default value with the withMeta function the data seems to be ignored.
For examle