Relationship between two dependent select fields

Hi everyone, how do I connect two selects to each other in the admin panel? I have a select customers and a contacts... the values of the select contacts must be filtered based on the value of the select customers
8 Replies
Timster8989
Timster898915mo ago
You didn't say whether you are in v3. But if you are, check here: https://filamentphp.com/docs/3.x/forms/fields/select#customizing-the-relationship-query Disabling specific options
NeerGreeN
NeerGreeNOP15mo ago
I tried this, but it doesn't work
Homd
Homd15mo ago
Attach the not working code
NeerGreeN
NeerGreeNOP15mo ago
Where am I doing wrong?
Homd
Homd15mo ago
I think here
Forms\Components\Select::make('contact_id')
->relationship('contact', 'name', fn(Builder $query) => $query->where('customer_id', request()->input('customer_id')))
->preload()
->label(__('activities.contact_id'))
->searchable(),
Forms\Components\Select::make('contact_id')
->relationship('contact', 'name', fn(Builder $query) => $query->where('customer_id', request()->input('customer_id')))
->preload()
->label(__('activities.contact_id'))
->searchable(),
Use $get instead https://filamentphp.com/docs/2.x/forms/advanced#dependant-fields--components
Homd
Homd15mo ago
Dan Harrin
YouTube
Dependant Select Inputs - Filament TALL Stack Form Builder
This video, we are using the filament/forms package. You can read the full documentation at: https://filamentadmin.com/docs/forms You can find out more about Filament on our website: https://filamentadmin.com Follow me on Twitter for more tutorials and other TALL stack tips: https://twitter.com/danjharrin If you found this video useful, pleas...
NeerGreeN
NeerGreeNOP15mo ago
Thank you very much!
Want results from more Discord servers?
Add your server