default value on form select not populating
I am attempting to have a value preselected when the Select item loads on a form. I only found two references to the default function in the docs, but no explanation on how to use it. I assume you pass an item that is in the options collection. Here is a snippet of what I tried:
$roles = Role::all()->pluck('name', 'id');
$defaultRole = $roles->first();
Select::make('role')
->options($roles)
->default($defaultRole)
Any reason why this isn't populating the default value?
5 Replies
my mistake, I was able to figure it out
->relationship('roles','name')
One small tip:
I didn't know that filament would automatically populate the value for me, that's convenient
just in case you need it somewhere else
nice I'll try that out. Thank you for the tip