FilamentF
Filament13mo ago
giapele

filament repeat issue inside widget

I have a filament repeater inside a widget with relationship method it i get error: Call to a member function reminders() on null. This repeater works just fine in a filament resource. This is the repeater:
Repeater::make('reminders')
->label(('labels.reminders'))
->relationship('reminders')
->default()
->schema([
TextInput::make('quantity')
->label(
('labels.reminder_quantity'))
->numeric()
->minValue(1)
->required(),

Select::make('unit')
->label(('labels.reminder_unit'))
->options([
'minutes' =>
('labels.minutes'),
'hours' => ('labels.hours'),
'days' =>
('labels.days'),
'weeks' => ('labels.weeks'),
])
->required(),

// Default name and description from the main event
TextInput::make('name')
->label(
('labels.reminder_name'))
->required(),

Textarea::make('description')
->label(('labels.reminder_description')),

Checkbox::make('notify_via_email')
->label(
('labels.notify_via_email'))
]),
Solution
customize the headerAction

protected function headerActions(): array
{
    return [
        Actions\CreateAction::make()
            ->form([
                TextInput::make('title')->required()->label(__('labels.title')),
                Repeater::make('reminders')
                    ->label(__('labels.reminders'))
                    ->relationship('reminders')
                    ->schema([
                        TextInput::make('name')
                            ->label(__('labels.reminder_name'))
                            ->required(),
                    ]),
            ]),
    ];
}
Was this page helpful?