Imam
Imam
FFilament
Created by Imam on 1/22/2024 in #❓┊help
Disable option Checkbox List more than 1 items
Solved! Just added with $set('technologies', ['special-option']);
->disableOptionWhen(function (string $value, $state): bool {
$tempData = $state ?? [];
$founSpecialOption = in_array('special-option', $tempData);

if($founSpecialOption) {
$set('technologies', ['special-option']);
return
$value === 'tailwind' || $value === 'alpine' || $value === 'laravel' || $value === 'livewire';
} else {
return false;
}
}),
->disableOptionWhen(function (string $value, $state): bool {
$tempData = $state ?? [];
$founSpecialOption = in_array('special-option', $tempData);

if($founSpecialOption) {
$set('technologies', ['special-option']);
return
$value === 'tailwind' || $value === 'alpine' || $value === 'laravel' || $value === 'livewire';
} else {
return false;
}
}),
7 replies
FFilament
Created by Imam on 1/22/2024 in #❓┊help
Disable option Checkbox List more than 1 items
No description
7 replies
FFilament
Created by Imam on 1/22/2024 in #❓┊help
Disable option Checkbox List more than 1 items
Thank you for your answer, this is my CheckboxList
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
'special-option' => 'Special Option'
])
->live()
->disableOptionWhen(function (string $value, $state): bool {
$tempData = $state ?? [];
$founSpecialOption = in_array('special-option', $tempData);

if($founSpecialOption) {
return
$value === 'tailwind' || $value === 'alpine' || $value === 'laravel' || $value === 'livewire';
} else {
return false;
}
}),
CheckboxList::make('technologies')
->options([
'tailwind' => 'Tailwind CSS',
'alpine' => 'Alpine.js',
'laravel' => 'Laravel',
'livewire' => 'Laravel Livewire',
'special-option' => 'Special Option'
])
->live()
->disableOptionWhen(function (string $value, $state): bool {
$tempData = $state ?? [];
$founSpecialOption = in_array('special-option', $tempData);

if($founSpecialOption) {
return
$value === 'tailwind' || $value === 'alpine' || $value === 'laravel' || $value === 'livewire';
} else {
return false;
}
}),
The next condition is, I want that when special-option is selected, the other options will automatically be unchecked, because if we disable them when any option is already checked, it will result in the following situation:
7 replies
FFilament
Created by Imam on 1/22/2024 in #❓┊help
How to make dynamic range Options Select Form Based on Selected State
It works! Thank you @toeknee
5 replies