Uncheck/Un-toggle other rows when checkbox is selected

I have a column called is_primary, and I'm using Toggle. What I need is that when I turn-on the Row#1, all the other rows will uncheck/untoggle. Now I'm using #table-repeater , it's the table version of the Repeater. So how to select all the rows to be uncheck (except for the toggle that I clicked? I'm guessing it's gonna be responsible of $set() or statePath()?
TableRepeater::make('parents_matrix')
->schema([
Toggle::make('is_primary')
->label('Primary?')
->reactive()
->afterStateUpdated(function(Closure $get, Closure $set, Toggle $component, $state){
if($get('is_primary')){
$set('is_primary', false);
}
}),
])
TableRepeater::make('parents_matrix')
->schema([
Toggle::make('is_primary')
->label('Primary?')
->reactive()
->afterStateUpdated(function(Closure $get, Closure $set, Toggle $component, $state){
if($get('is_primary')){
$set('is_primary', false);
}
}),
])
1 Reply
vahnmarty
vahnmartyOP2y ago
I did have a solution, but I'm not sure if it's good way, that's why i'm looking for a Filament way to solve this.
if($get('is_primary')){

foreach($this->data['parents_matrix'] as $uuid => $item)
{
if($item['id'] != $get('id')){
$this->data['parents_matrix'][$uuid]['is_primary'] = false;
}
}
}
if($get('is_primary')){

foreach($this->data['parents_matrix'] as $uuid => $item)
{
if($item['id'] != $get('id')){
$this->data['parents_matrix'][$uuid]['is_primary'] = false;
}
}
}
Want results from more Discord servers?
Add your server