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 ```php protected function headerActions(): array {...
Jump to solution
18 Replies
giapele
giapeleOP4w ago
Flare
Call to a member function reminders() on null - Occurred on URL http://127.0.0.1:8000/admin
LeandroFerreira
are you using a custom livewire component?
giapele
giapeleOP4w ago
Νο this is inside the app/filament/widgets/calendarwidget and using the saade plugin
giapele
giapeleOP4w ago
this is the full resource
php
php
LeandroFerreira
could you share the form code?
LeandroFerreira
reminders relationship is null at this moment. If you are using a livewire component, I think you should do this when you are using relationships, but honestly I didn't understand your code and where are you rendering the form. Maybe you could provide a minimal repo on Github to reproduce this issue
giapele
giapeleOP4w ago
I don't use livewire. A Made a minimal repo and i reproduce the issue https://github.com/giapele/test-app
GitHub
GitHub - giapele/test-app
Contribute to giapele/test-app development by creating an account on GitHub.
giapele
giapeleOP4w ago
the events from the resource work fine but with the same code on the calendarwidget i can view the created events but i can't create i get the previous error
Solution
LeandroFerreira
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(),
]),
]),
];
}
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(),
]),
]),
];
}
giapele
giapeleOP4w ago
thank you the create work, but now on view it shows empty
LeandroFerreira
what view?
giapele
giapeleOP4w ago
when i click the event on the calendar it opens the event but it looking for the getFormSchema i previously using
LeandroFerreira
I think you can customize all actions, View, Edit..
protected function viewAction(): Action
{
return Actions\ViewAction::make()
->infolist([
TextEntry::make('title'),
...
]);
}
protected function viewAction(): Action
{
return Actions\ViewAction::make()
->infolist([
TextEntry::make('title'),
...
]);
}
giapele
giapeleOP4w ago
yes but this way i will have the form dublicate and if I add a field i don't want to have to add it 2 times
LeandroFerreira
ask on #saade-fullcalendar maybe someone can help you
giapele
giapeleOP4w ago
ok thank you
giapele
giapeleOP4w ago
i did this and it works
protected function schema(): array
{
return [
TextInput::make('title')->required()->label(__('labels.title')),
Repeater::make('reminders')
->label(__('labels.reminders'))
->relationship()
->schema([
TextInput::make('name')
->label(__('labels.reminder_name'))
->required(),

]),
DateTimePicker::make('start')->required()->label(__('labels.event_start'))->withoutSeconds()->native(false),
];
}

protected function headerActions(): array
{
return [
Actions\CreateAction::make()
->form($this->schema()),
];
}

protected function viewAction(): Actions\ViewAction
{
return Actions\ViewAction::make()
->form($this->schema());
}
protected function schema(): array
{
return [
TextInput::make('title')->required()->label(__('labels.title')),
Repeater::make('reminders')
->label(__('labels.reminders'))
->relationship()
->schema([
TextInput::make('name')
->label(__('labels.reminder_name'))
->required(),

]),
DateTimePicker::make('start')->required()->label(__('labels.event_start'))->withoutSeconds()->native(false),
];
}

protected function headerActions(): array
{
return [
Actions\CreateAction::make()
->form($this->schema()),
];
}

protected function viewAction(): Actions\ViewAction
{
return Actions\ViewAction::make()
->form($this->schema());
}
Want results from more Discord servers?
Add your server