Nested Repeater data not pre-populated to edit form
Hello,
I had used Nested Repeater for parent child elements added dynamically,
it willl work and also saved in database but when i open edit for child repeater data is not pre-populated.
please help me to sort out this.
following is my code.
I also attached my menu model and menumapping model.
this code is done in menuResource,
5 Replies
the code is so long, and hard to debug by just reading it
so here is some steps to try:
- try disable
afterStateUpdated
! and see if it works
- add only one field in the repeater and the nested repeater, easier to read the code.
- if you query outside filament like model->with(relation.subrelation)->get()
dose the data come out correctly (could be relation issue in the model)!Tabs\Tab::make('Plan Your Meal')
->schema([
Forms\Components\Repeater::make('menumapping') ->relationship('menumapping') // Parent relationship ->label('') ->createItemButtonLabel('Add Menu') ->schema([
Forms\Components\Select::make('menu_category_id') ->label('') ->relationship('category', 'name') ->searchable() ->columns(4) ->reactive() ->preload(),
Forms\Components\Repeater::make('childMenuMappings') ->relationship() ->label('') ->createItemButtonLabel('Add Article') ->schema([ Forms\Components\TextInput::make('display_name') ->label('Display Name'), Forms\Components\TextInput::make('qty') ->label('Qty')->default(1) ->numeric() ->minValue(1), ]) ])
]) ->columnSpan('full') This is simple code. still not child repeater is not pre-populated in edit form
Forms\Components\Repeater::make('menumapping') ->relationship('menumapping') // Parent relationship ->label('') ->createItemButtonLabel('Add Menu') ->schema([
Forms\Components\Select::make('menu_category_id') ->label('') ->relationship('category', 'name') ->searchable() ->columns(4) ->reactive() ->preload(),
Forms\Components\Repeater::make('childMenuMappings') ->relationship() ->label('') ->createItemButtonLabel('Add Article') ->schema([ Forms\Components\TextInput::make('display_name') ->label('Display Name'), Forms\Components\TextInput::make('qty') ->label('Qty')->default(1) ->numeric() ->minValue(1), ]) ])
]) ->columnSpan('full') This is simple code. still not child repeater is not pre-populated in edit form
it display like this not come child articles as there is aready in database.
tried this?
if you query outside filament like model->with(relation.subrelation)->get() dose the data come out correctly (could be relation issue in the model)!
here is another example:
sections
and inside them fields
https://github.com/lara-zeus/bolt/blob/283c8606e1899a7c35959710b42cecb9c1c5f85b/src/Concerns/Schemata.php#L107( could be relation issue in the model ) U can check both models are attached already, Please guid if any relation issues in model.
model->with(relation.subrelation)->get() in which file or function i can call this?