Skip to content

feat: get item index in itemLabel on Repeater#19296

Closed
pintend wants to merge 1 commit intofilamentphp:5.xfrom
pintend:feat-repeater-itemlabel-index
Closed

feat: get item index in itemLabel on Repeater#19296
pintend wants to merge 1 commit intofilamentphp:5.xfrom
pintend:feat-repeater-itemlabel-index

Conversation

@pintend
Copy link

@pintend pintend commented Feb 18, 2026

passes the index to getItemLabel() so we can do something like this

Repeater::make()
    ->itemLabel(function (int $index) {
        return match($index) {
            1 => 'Primary',
            default => 'Backup',
        };
    })
image

@github-project-automation github-project-automation bot moved this to Todo in Roadmap Feb 18, 2026
@pintend pintend changed the base branch from 4.x to 5.x February 18, 2026 17:42
@People-Sea
Copy link
Member

People-Sea commented Feb 18, 2026

Please rebase onto 4.x

@foreach ($items as $itemKey => $item)
@php
$itemLabel = $getItemLabel($itemKey);
$itemLabel = $getItemLabel($itemKey, $loop->iteration);
Copy link
Member

@People-Sea People-Sea Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be $loop->index instead? Since the injected parameter is named $index, it should start at 0 to match convention.

@danharrin danharrin added enhancement New feature or request pending changes labels Feb 19, 2026
@danharrin danharrin modified the milestones: v5, v4 Feb 19, 2026
@danharrin
Copy link
Member

Please reopen on 4.x

@danharrin danharrin closed this Feb 28, 2026
@github-project-automation github-project-automation bot moved this from Todo to Done in Roadmap Feb 28, 2026
@pintend
Copy link
Author

pintend commented Mar 5, 2026

Replaced by #19430

@pintend pintend deleted the feat-repeater-itemlabel-index branch March 5, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants