FilamentF
Filament6mo ago
lukevi

repeater in modal $record is empty

I'm having trouble populating my repeater in this action modal - even though the same repeater works perfectly when not in the modal (I've put it there only for troubleshooting - I only want the modal one). I can see that the relationship query does get executed by the modal repeater, but my text inputs there get only a null $record every time. Do I need a different parameter to access the record there? TIA for any pointers!

# this one works as expected
Repeater::make('projects')
    ->relationship('projects')
    ->schema([
        TextInput::make('name')
            ->formatStateUsing(fn ($record) => $record?->name),
        TextInput::make('status')
            ->formatStateUsing(fn ($record) => $record?->status),
    ]),

TextInput::make('# projects')
    ->hintAction(
        Action::make('view projects')
          ->form([

            # this one though, within an action form on the same page...
            Repeater::make('projects')
              ->relationship('projects')
              ->schema([
                # ... $record is null, calculated state fails
                TextInput::make('name')
                  ->formatStateUsing(fn ($record) => $record?->name),
                TextInput::make('status')
                  ->formatStateUsing(fn ($record) => $record?->status),
              ])
          ])
    ),
Was this page helpful?