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
giapeleOP3mo ago
Flare
Call to a member function reminders() on null - Occurred on URL http://127.0.0.1:8000/admin
LeandroFerreira
LeandroFerreira3mo ago
are you using a custom livewire component?
giapele
giapeleOP3mo ago
Νο this is inside the app/filament/widgets/calendarwidget and using the saade plugin
giapele
giapeleOP3mo ago
this is the full resource
php
php
LeandroFerreira
LeandroFerreira3mo ago
could you share the form code?
giapele
giapeleOP3mo ago
LeandroFerreira
LeandroFerreira3mo ago
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
giapeleOP3mo 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
giapeleOP3mo 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
LeandroFerreira3mo ago
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
giapeleOP3mo ago
thank you the create work, but now on view it shows empty
LeandroFerreira
LeandroFerreira3mo ago
what view?
giapele
giapeleOP3mo ago
when i click the event on the calendar it opens the event but it looking for the getFormSchema i previously using
LeandroFerreira
LeandroFerreira3mo ago
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
giapeleOP3mo 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
LeandroFerreira3mo ago
ask on #saade-fullcalendar maybe someone can help you
giapele
giapeleOP3mo ago
ok thank you
giapele
giapeleOP3mo 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());
}

Did you find this page helpful?