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);
                                })


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')
                ,


Any ideas of how I can fill the field DESCRIPTION inside the repeater called ACTIONS ????

Tks.
image.png
image.png
image.png
Solution
the repeater is an array of arrays.
[
  ['description' => 'blah'],
  ['description' => 'blah2'],
  ...
]
Was this page helpful?