nested repeater extraItemActions
I have 2 nested repeaters and on the second I have extraItemActions and I have mountUsing and the $record for somereason is the data from the parent repeater and not the child
here is the code:
Repeater::make('Tasklists')
->relationship('tasklists')
->schema([
TextInput::make('name')
->label('Tasklist Name')
->required(),
Repeater::make('Cards')
->relationship('cards')
->schema([... ])
->extraItemActions([
Action::make('editCard')
->icon('heroicon-o-pencil')
->mountUsing(function (Forms\ComponentContainer $form, $record) {
log::info('', ['record' => $record]);
})
->action(function ($record, array $data) {
...
})
->form([... ])
])
])
->label('Cards')
->addActionLabel('Add New Card'),
])
->columnSpan('full')
->grid(5)
->addActionLabel('Add New Tasklist'),
])
if I log $record->cards I get all cards but i don't know the id of the card I am currently editing
here is the code:
Repeater::make('Tasklists')
->relationship('tasklists')
->schema([
TextInput::make('name')
->label('Tasklist Name')
->required(),
Repeater::make('Cards')
->relationship('cards')
->schema([... ])
->extraItemActions([
Action::make('editCard')
->icon('heroicon-o-pencil')
->mountUsing(function (Forms\ComponentContainer $form, $record) {
log::info('', ['record' => $record]);
})
->action(function ($record, array $data) {
...
})
->form([... ])
])
])
->label('Cards')
->addActionLabel('Add New Card'),
])
->columnSpan('full')
->grid(5)
->addActionLabel('Add New Tasklist'),
])
if I log $record->cards I get all cards but i don't know the id of the card I am currently editing
Solution
try using
https://filamentphp.com/docs/3.x/forms/fields/repeater#adding-extra-item-actions-to-a-repeater
arguments to get the current item https://filamentphp.com/docs/3.x/forms/fields/repeater#adding-extra-item-actions-to-a-repeater