F
Filament2w ago
B.M

How to get the live order of repeater item

Hello everyone I wonder if there is a way to get the repeater item order position inside a repeater field on reorder with buttons or drag-and-drop, regardless of the database order column, I have a repeater field
return Repeater::make('steps')
->relationship()
->schema(static::getSchema())
->columns(1)
->collapsed()
->collapsible()
->itemLabel(fn(array $state): ?string => $state['name'][App::getLocale()] ?? __('app.new_step'))
->addActionLabel(__('app.add_step'))
->reorderable()
->reorderableWithButtons()
->orderColumn('order')
->defaultItems(0);
return Repeater::make('steps')
->relationship()
->schema(static::getSchema())
->columns(1)
->collapsed()
->collapsible()
->itemLabel(fn(array $state): ?string => $state['name'][App::getLocale()] ?? __('app.new_step'))
->addActionLabel(__('app.add_step'))
->reorderable()
->reorderableWithButtons()
->orderColumn('order')
->defaultItems(0);
so when an item is reordered, is there a way ro access the new order of the item instantly? thanks in advance
Solution:
solution is
$state = $get('data.steps', true);
$order = array_keys($state);
$state = $get('data.steps', true);
$order = array_keys($state);
`...
Jump to solution
1 Reply
Solution
B.M
B.M2w ago
solution is
$state = $get('data.steps', true);
$order = array_keys($state);
$state = $get('data.steps', true);
$order = array_keys($state);
` thanks everyone

Did you find this page helpful?