© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
szucs996#1

Dynamic Select field default value HELP PLEASE <3

Hi,
I have the following code:
Select::make('organisation_id')
                                ->relationship('organisations','label')
                                ->live()
                                ->required()
                                ->afterStateUpdated(function($state,$set,$component,$livewire){
                                    if($state) {
                                        $default=Organisation::find($state)->defaultInvoiceRecipient;
                                        if ($default) {
                                            $set('invoice_recipient_id', $default->id);
                                        }
                                    }

                                }),
                            Select::make('invoice_recipient_id')
                                ->visible(fn($get)=>$get('organisation_id'))
                                ->required()
                                ->relationship('invoiceRecipient', 'company_entity',function ($query,$get,$set){
                                    if($get('organisation_id')){
                                        $query->where('organisation_id',$get('organisation_id'));
                                    }
                                })
Select::make('organisation_id')
                                ->relationship('organisations','label')
                                ->live()
                                ->required()
                                ->afterStateUpdated(function($state,$set,$component,$livewire){
                                    if($state) {
                                        $default=Organisation::find($state)->defaultInvoiceRecipient;
                                        if ($default) {
                                            $set('invoice_recipient_id', $default->id);
                                        }
                                    }

                                }),
                            Select::make('invoice_recipient_id')
                                ->visible(fn($get)=>$get('organisation_id'))
                                ->required()
                                ->relationship('invoiceRecipient', 'company_entity',function ($query,$get,$set){
                                    if($get('organisation_id')){
                                        $query->where('organisation_id',$get('organisation_id'));
                                    }
                                })

When you select the
organisation_id
organisation_id
should automatically select the default value of the
invoice_recipient_id
invoice_recipient_id
but unfortunately doesn't.
Can you assist please?
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

Select field default value
FilamentFFilament / ❓┊help
3y ago
Default value for select
FilamentFFilament / ❓┊help
3y ago
Select default value from select dropdown
FilamentFFilament / ❓┊help
17mo ago
Default value in Select input
FilamentFFilament / ❓┊help
2y ago