CheckboxList::make('list')
->label('Question here (Check all that apply)')
->options([
'A' => 'A',
'B' => 'B',
'C' => 'C',
'None of the Above' => 'None of the Above',
])
->live()
->required()
->afterStateUpdated(function(Livewire $livewire, CheckboxList $component, Get $get, Set $set, $old, $state){
$noneString = 'None of the above';
if (is_array($state)){
if(in_array($noneString, $old)){
$selected = array_diff($state, [$noneString]);
}
elseif(in_array($noneString, $state)){
$selected = [$noneString];
}
$set($component->getStatePath(), $selected);
/**
WHAT'S THE CODE HERE? TO LIKE REFRESH THE FORM OR THIS FIELD.
something like $livewire->refresh()?
**/
}
})
CheckboxList::make('list')
->label('Question here (Check all that apply)')
->options([
'A' => 'A',
'B' => 'B',
'C' => 'C',
'None of the Above' => 'None of the Above',
])
->live()
->required()
->afterStateUpdated(function(Livewire $livewire, CheckboxList $component, Get $get, Set $set, $old, $state){
$noneString = 'None of the above';
if (is_array($state)){
if(in_array($noneString, $old)){
$selected = array_diff($state, [$noneString]);
}
elseif(in_array($noneString, $state)){
$selected = [$noneString];
}
$set($component->getStatePath(), $selected);
/**
WHAT'S THE CODE HERE? TO LIKE REFRESH THE FORM OR THIS FIELD.
something like $livewire->refresh()?
**/
}
})