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 should automatically select the default value of the invoice_recipient_id but unfortunately doesn't. Can you assist please?
4 Replies
szucs996#1
szucs996#1OP8mo ago
That's the default value, and I can see that it's being populated, just not showing:
No description
szucs996#1
szucs996#1OP8mo ago
No description
LeandroFerreira
LeandroFerreira8mo ago
GitHub
Automatically choose 1st option in dependent Select component · fil...
Package Form builder Package Version v3.2.52 How can we help you? I've created a Filament form in which I have dependent Select components. I choose a "client" (i.e. a company name) f...
szucs996#1
szucs996#1OP8mo ago
lovely works. Thanks ❤️
Want results from more Discord servers?
Add your server