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';
  })


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'];
})
image.png
image.png
Was this page helpful?