Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filamentβ€’6mo agoβ€’
3 replies
larsbo

How to preselect a MorphToSelect?

I have a
MorphToSelect::make('inspectable')
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
modifyOptionsQueryUsing
πŸ™ˆ πŸ˜†
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel β€’ Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to preselect a CheckboxList
FilamentFFilament / β“β”Šhelp
3y ago
Preselect table Bulk
FilamentFFilament / β“β”Šhelp
17mo ago
Set MorphToSelect to a value in mount()
FilamentFFilament / β“β”Šhelp
3y ago
Default MorphToSelect value
FilamentFFilament / β“β”Šhelp
2y ago