Select field with Checkbox
Hello again all,
I want to disable a basic select field when checkbox is checked, I made both components reactive and getting the checkbox component's state in disabled closure correctly, even Select disabled function gets called after checkbox updated
But the even if checkbox disabled state returning false, select disabled state is not changing. It stays same as if the first page load state. Am I missing something?
Here is my code;
Checkbox::make('send_all_users')
->label('Send to everyone')
->inline()
->reactive(),
Select::make('branch_ids')
->reactive()
->label('Choose branch ids')
->hint('Seçili şube üyelerine gönderin')
->multiple()
->searchable()
->options(fn () =>
Branch::where('corp_id', $authUser->corp_id)
->get()
->pluck('title', 'id')
)
->disabled(function (Closure $get) {
error_log('send_all_users: ' . !boolval($get('send_all_users')));
return !boolval($get('send_all_users'));
}),
2 Replies
its not possible to do it on searchable selects or multiselects. sorry
its a livewire limitation that maybe we can look into fixing in v3
the only way to get close is by hiding the multiselect instead of disabling it with hidden()
Ah okey, will hide them until the big v3 will become alive 🙂 Thanks.