F
Filamentβ€’5w ago
larsbo

How to preselect a MorphToSelect?

I have a MorphToSelect::make('inspectable') and want to pre-fill it via url. In my CreateRecord component I use the mount() method.
public function mount(): void
{
parent::mount();

$this->form->fill([
'inspectable_type' => request('inspectable_type'),
'inspectable_id' => request('inspectable_id'),
]);
}
public function mount(): void
{
parent::mount();

$this->form->fill([
'inspectable_type' => request('inspectable_type'),
'inspectable_id' => request('inspectable_id'),
]);
}
If I open the url the type select is set correctly but the id select shows the id and not the type value. Btw: I'm pretty sure it worked in the v4 beta πŸ˜€
Solution:
Nvm: The given id was filtered out via modifyOptionsQueryUsing πŸ™ˆ πŸ˜†
Jump to solution
1 Reply
Solution
larsbo
larsboβ€’5w ago
Nvm: The given id was filtered out via modifyOptionsQueryUsing πŸ™ˆ πŸ˜†

Did you find this page helpful?