How to dynamically fill repeater items in create form

Hi. I need to fill several repeater items dynamically. At the moment, the "empty" lines are being created as expected (I mean 3 or 4 items), but the one only field called "description" is not filled; My code includes a TableRepeater::make ('actions') and inside there is one only field in the schema, called description. My code works afterStateUpdated and goes like this:
return $form
->schema([
Fieldset::make()
->schema([
TextInput::make('description')
->label(__('description'))
->live()
->afterStateUpdated(function (Set $set, Get $get, $state) {
$misAcciones = [
'action01',
'action02',
'action03'
];
$set('actions', $misAcciones ?? null);
})
return $form
->schema([
Fieldset::make()
->schema([
TextInput::make('description')
->label(__('description'))
->live()
->afterStateUpdated(function (Set $set, Get $get, $state) {
$misAcciones = [
'action01',
'action02',
'action03'
];
$set('actions', $misAcciones ?? null);
})
And below is the repeater part:
TableRepeater::make('actions')
->relationship()
->label(__('actions'))
->schema([
TextInput::make('description')->required()->label(__('actionTypeDescription'))
->placeholder(__('actionTypeDescription')),
])->minItems(2)->reorderable(true)->reorderableWithButtons()->orderColumn('order_column')
->addActionLabel('Añadir + Acciones')
,
TableRepeater::make('actions')
->relationship()
->label(__('actions'))
->schema([
TextInput::make('description')->required()->label(__('actionTypeDescription'))
->placeholder(__('actionTypeDescription')),
])->minItems(2)->reorderable(true)->reorderableWithButtons()->orderColumn('order_column')
->addActionLabel('Añadir + Acciones')
,
Any ideas of how I can fill the field DESCRIPTION inside the repeater called ACTIONS ???? Tks.
Solution:
the repeater is an array of arrays. ```php [ ['description' => 'blah'], ['description' => 'blah2'],...
Jump to solution
2 Replies
Solution
awcodes
awcodes16mo ago
the repeater is an array of arrays.
[
['description' => 'blah'],
['description' => 'blah2'],
...
]
[
['description' => 'blah'],
['description' => 'blah2'],
...
]
Albert Lens
Albert LensOP16mo ago
It works now. Thank you very much for the info "array of arrays". That makes it absolutely clear. Tks.
Want results from more Discord servers?
Add your server