Open sheepbild opened 1 year ago
it happens with MorphToSelect too.
Hello, I tried to use Repeator with BelongsToMany relationship. The classes are "Event (object in calendar)" -> "Reservation" <- "User (student)". If I use the same code in a classical FilamentPHP Edit page, my "Repeator" function looks fine. When I click on "Save" I've this issue :
Call to a member function reservations() on null
Docs : https://filamentphp.com/docs/3.x/forms/fields/repeater
My getFormSchema() function :
[ View::make('forms.components.title-event'), DateTimePicker::make('start') ->label('Début') ->default(now()) ->seconds(false) ->required(), DateTimePicker::make('end') ->label('Fin') ->default(now()) ->seconds(false) ->required(), Repeater::make('reservations') ->relationship() ->schema([ Select::make('student_id') ->label('Participant') ->required() ->relationship('student', 'name') ->options(User::all()->sortBy('name')->pluck('name', 'id')) ->searchable() ->default(null), Toggle::make('has_participated') ->label('A participé'), Toggle::make('is_paid') ->label('Payé'), ]) ->columns(1) ]
Full classes : https://github.com/sheepbild/filament-viewcolumn-bug/tree/main/belongsToMany-repeater
Make sure in your Custom Widget Class to include these 2 methods
protected function getFormModel(): Model|string|null { return $this->event ?? Reservation::class; }
public function resolveEventRecord(array $data): Reservation { return Reservation::find($data['id']); }
Hello, I tried to use Repeator with BelongsToMany relationship. The classes are "Event (object in calendar)" -> "Reservation" <- "User (student)". If I use the same code in a classical FilamentPHP Edit page, my "Repeator" function looks fine. When I click on "Save" I've this issue :
Call to a member function reservations() on null
Docs : https://filamentphp.com/docs/3.x/forms/fields/repeater My getFormSchema() function :[ View::make('forms.components.title-event'), DateTimePicker::make('start') ->label('Début') ->default(now()) ->seconds(false) ->required(), DateTimePicker::make('end') ->label('Fin') ->default(now()) ->seconds(false) ->required(), Repeater::make('reservations') ->relationship() ->schema([ Select::make('student_id') ->label('Participant') ->required() ->relationship('student', 'name') ->options(User::all()->sortBy('name')->pluck('name', 'id')) ->searchable() ->default(null), Toggle::make('has_participated') ->label('A participé'), Toggle::make('is_paid') ->label('Payé'), ]) ->columns(1) ]
Full classes : https://github.com/sheepbild/filament-viewcolumn-bug/tree/main/belongsToMany-repeater
Make sure in your Custom Widget Class to include these 2 methods
protected function getFormModel(): Model|string|null { return $this->event ?? Reservation::class; }
public function resolveEventRecord(array $data): Reservation { return Reservation::find($data['id']); }
Thank you very much. I have been trying to debug this issue for whole afternoon. !
Hello, I tried to use Repeator with BelongsToMany relationship. The classes are "Event (object in calendar)" -> "Reservation" <- "User (student)". If I use the same code in a classical FilamentPHP Edit page, my "Repeator" function looks fine. When I click on "Save" I've this issue :
Call to a member function reservations() on null
Docs : https://filamentphp.com/docs/3.x/forms/fields/repeater
My getFormSchema() function :
Full classes : https://github.com/sheepbild/filament-viewcolumn-bug/tree/main/belongsToMany-repeater