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#13mo ago
That's the default value, and I can see that it's being populated, just not showing:
No description
szucs996#1
szucs996#13mo ago
No description
LeandroFerreira
LeandroFerreira3mo 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#13mo ago
lovely works. Thanks ❤️
Want results from more Discord servers?
Add your server
More Posts
Testing custom auth guardHi, i have a panel that uses a custom authGuard and custom login page, defined in the panel like thiOpen a blocking modal on login based on a condition.Hello! I was wondering if there is any way to open a form modal that would block the user from usingText input for selectboxHi there! I am still relatively new to Filament, but loving it so far! I do have a question regardiHow to add client side code to take values from a field in real time and adding them in filament ?How to add client side code I read docs but not able to understand how can I do it ?`requiresConfirmation(false)` still shows confirmation dialog for Delete actionI have the following table action ```php Actions\DeleteAction::make('delete')) ->icon('heroiconError when deploying to production using Laravel Forge, svg path not foundHas anyone run into this when deploying to production? I'm using laravel forge. "The path for the dCharacters are removed on browser auto-fillHi, when I use the auto fill function of my browser the input field removes characters (see the vidDownloading Error conflicts with another requireI am using windows when i want to install ``composer require filament/filament:"^3.2" -W`` ```>> TDateTimePicker IssueI am using DateTimePicker field i am using its timezone method i need to show in ui date time in accopen_basedir restriction in effect : FileUpload::make('attachment')Hello, I've been having an issue for several days now... When I perform a "simple" upload directly