Repeater show field based on line number

Hello,

I would like to display a field in my repeater only if the current repeated element is not the first.

I've done this code that works well but I'm sure there is a better way to do it :

->visible(function (Component $component, Get $get) {
  if ($get('../../conditions') === null) {
    return false;
  }

  $statePath = $component->getContainer()->getStatePath();
  $statePath = explode('.', $statePath);
  $statePath = end($statePath);
  
  if (array_key_first($get('../../conditions')) === $statePath) {
    return false;
  }

  return true;
})


Best regards
Was this page helpful?