Repeater DeleteAction

Repater context why visible is called twice? the first time without $activeItem. I am trying to hide delete button only for some item. In this way the button result disabled, not hidden.
->visible(function (array $arguments, Repeater $component): bool {
$items = $component->getState();
$activeItem = $items[$arguments['item'] ?? null] ?? null;

dump($activeItem);
if (!$activeItem || !$activeItem['role_id']) return true;
return !self::$ownerRoles->find($activeItem['role_id']);
})->color(function (array $arguments, Repeater $component): string {
$items = $component->getState();
$activeItem = $items[$arguments['item'] ?? null] ?? null;

//dump($activeItem);
if (!$activeItem || !$activeItem['role_id']) return 'danger';
return !self::$ownerRoles->find($activeItem['role_id']) ? 'danger' : 'gray';
})
->visible(function (array $arguments, Repeater $component): bool {
$items = $component->getState();
$activeItem = $items[$arguments['item'] ?? null] ?? null;

dump($activeItem);
if (!$activeItem || !$activeItem['role_id']) return true;
return !self::$ownerRoles->find($activeItem['role_id']);
})->color(function (array $arguments, Repeater $component): string {
$items = $component->getState();
$activeItem = $items[$arguments['item'] ?? null] ?? null;

//dump($activeItem);
if (!$activeItem || !$activeItem['role_id']) return 'danger';
return !self::$ownerRoles->find($activeItem['role_id']) ? 'danger' : 'gray';
})
attachment show the double call This hide the button
->extraAttributes(function (array $arguments, Repeater $component): array {
$items = $component->getState();
$activeItem = $items[$arguments['item'] ?? null] ?? null;

if (!$activeItem || !$activeItem['role_id']) return [];
return !self::$ownerRoles->find($activeItem['role_id']) ? [] : ['class' => 'hidden'];
})
->extraAttributes(function (array $arguments, Repeater $component): array {
$items = $component->getState();
$activeItem = $items[$arguments['item'] ?? null] ?? null;

if (!$activeItem || !$activeItem['role_id']) return [];
return !self::$ownerRoles->find($activeItem['role_id']) ? [] : ['class' => 'hidden'];
})
No description
No description
4 Replies
toeknee
toekneethis hour
Is the field live? Would you not use ->deletable() ?
galli.roberto
galli.robertoOP11h ago
How could I use it? Deletable is global for all whole repeater...
toeknee
toeknee9h ago
GitHub
Repeater conditional deletable per item · filamentphp filament · Di...
Hello Expert Can you guide me please on how to show delete action for selected Repeater items? I don't want to allow user to delete all items, some items are mandatory, so I want to remove the ...
galli.roberto
galli.robertoOP6h ago
I do mine follow that. Do you try the things before write? That solution disable action
Want results from more Discord servers?
Add your server