Repeater in a Custom Page Not Loading HasMany Relationship Data

I'm working on a Custom Page in Filament v3 and trying to display a HasMany relationship inside a Repeater. The issue is that the repeater correctly generates the right number of items, but the fields remain empty.
10 Replies
toeknee
toeknee5w ago
Please provider your Custom Page.
Huberson Kouakou
Huberson KouakouOP5w ago
use Filament\Forms\Components\Repeater; use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; use Filament\Resources\Pages\Concerns\InteractsWithRecord; use Filament\Resources\Pages\Page; use App\Models\Offer; class ShowOfferDetails extends Page { protected static string $resource = OfferResource::class; protected static string $view = 'filament.resources.offer-resource.pages.show-offer-details'; use InteractsWithRecord; public function mount(int | string $record): void { $this->record = $this->resolveRecord($record)->load('partsSubscribed'); $this->form->fill(); } public function getFormModel(): Offer { return $this->record; } protected function getFormSchema(): array { return [ Section::make([ Section::make('Réassurance') ->schema([ Repeater::make('subscribedParts') ->relationship('subscribedParts') ->schema([ Placeholder::make('') ->label('Société de réassurance') ->content($this->record->name),
TextInput::make('contact_email') ->label('Contact email') ->email() ->required(), ]) ->addable(false) ->deletable(false) ->reorderable(false) ]) ->collapsed() ->columnSpanFull() ])->columns(4), ]; } }
toeknee
toeknee5w ago
Because you have set $this->form->fill(); without any data? Do: $this->form->fill($this->record); might need ->toArray()
Huberson Kouakou
Huberson KouakouOP5w ago
I added $this->form->fill($this->record->toArray()); in the mount method, but the repeater still doesn't load the data.
toeknee
toeknee5w ago
Remove the form->fill I have a feeling it's not needed and loaded with the interactiosnw ith record
Huberson Kouakou
Huberson KouakouOP5w ago
When I remove form->fill, the repeater no longer displays the fields. When I add it, the fields are displayed but empty.
toeknee
toeknee5w ago
This is interesting... someone has reported similar with repeaterEntry too... I have a feeling it could be your camel case... What relationship name on the model
Huberson Kouakou
Huberson KouakouOP5w ago
The relationship name is "partsSubscribed"
toeknee
toeknee5w ago
IS it? Because on the repeater you said it is:
->relationship('subscribedParts')
->relationship('subscribedParts')
Try making it all lowercase and try for me again
Huberson Kouakou
Huberson KouakouOP5w ago
Yes, it's indeed 'subscribedParts', I made a mistake.

Did you find this page helpful?