Conditional form relationships

Is there a way to fetch related models, in the same form, based on another field value?
Select::make('user_id')
->label('User')
->options(User::all()->pluck('name', 'id'))
->required(),
Select::make('post_id')
->label('Post')
->options(Post::where('author_id', 'SELECTED-USER-ID?')->get()->pluck('name', 'id'))
->required(),
Select::make('user_id')
->label('User')
->options(User::all()->pluck('name', 'id'))
->required(),
Select::make('post_id')
->label('Post')
->options(Post::where('author_id', 'SELECTED-USER-ID?')->get()->pluck('name', 'id'))
->required(),
1. Is there a way to list posts by the selected user? SELECTED-USER-ID 2. Is there a way to disable the post select field until a user is selected?
4 Replies
toeknee
toekneeβ€’2y ago
Filament
Advanced - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
Dennis Koch
Dennis Kochβ€’2y ago
Filament
Advanced - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
Dennis Koch
Dennis Kochβ€’2y ago
For 2) You are looking for Closure Customization
Vincent Klaiber
Vincent KlaiberOPβ€’2y ago
Thanks! πŸ™‡β€β™‚οΈ This worked out great. Filament is truly amazing πŸ”₯
Want results from more Discord servers?
Add your server