Tricks

Make it easier for your users by selecting the last selected choices

Jan 4, 2023
Andreas Kviby
Form builder

We are building large systems using Filament as the Framework. On a lot of pages the users wants to have their last selected choice preselected. So we did that now on all pages, we also thought that it is a trick. It might not be but if someone haven't done it, do it. The users love it.

Select::make('category_id')
->relationship('category', 'name')->label('Category')
->default(
Model::query()
->latest('created_at')
->pluck('category_id') ?
Model::query()
->latest('created_at')
->pluck('category_id')
->first() :
null
),

It is really easy, don't forget to modify the Model to your model and the fields as well. Happy Filamenting!

No comments yet…