Filament: RepeatableEntry not showing relationship data from model

I’m trying to display data from a $section model inside a Filament RepeatableEntry. When I use TextEntry, the details show up just fine. However, when I try to show the related students with RepeatableEntry, nothing is displayed. Here’s the full code for my SectionDetails page
class SectionDetails extends Page
{

protected static bool $shouldRegisterNavigation = false;
protected static ?string $slug = 'manage-sections/{section}';
public ?Section $section = null;

public function mount(Section $section): void
{
$this->section = $section;
}


public function schema(Schema $schema): Schema
{
return $schema
->record($this->section)
->components([
Tabs::make('Tabs')
->tabs([
Tab::make('Details')
->schema([
TextEntry::make('name')->label('Section Name'),
TextEntry::make('course.name')->label('Course'),

// This works with TextEntry but not RepeatableEntry
RepeatableEntry::make('students')
->schema([
TextEntry::make('name')->label('Student Name'),
TextEntry::make('email')->label('Email'),
])
->columns(1)
->contained(false)
->grid(3),
]),
]),
]);
}
}
class SectionDetails extends Page
{

protected static bool $shouldRegisterNavigation = false;
protected static ?string $slug = 'manage-sections/{section}';
public ?Section $section = null;

public function mount(Section $section): void
{
$this->section = $section;
}


public function schema(Schema $schema): Schema
{
return $schema
->record($this->section)
->components([
Tabs::make('Tabs')
->tabs([
Tab::make('Details')
->schema([
TextEntry::make('name')->label('Section Name'),
TextEntry::make('course.name')->label('Course'),

// This works with TextEntry but not RepeatableEntry
RepeatableEntry::make('students')
->schema([
TextEntry::make('name')->label('Student Name'),
TextEntry::make('email')->label('Email'),
])
->columns(1)
->contained(false)
->grid(3),
]),
]),
]);
}
}
The issue is: TextEntry works and shows the section’s data correctly. RepeatableEntry does not show the students relationship data. My question: What’s the correct way to pass the related students from the $section model into a RepeatableEntry so that it renders properly?
Solution:
Can you try: ```php public function mount(Section $section): void {...
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Koch20h ago
Can you try:
public function mount(Section $section): void
{
$this->section = $section;
$this->section->loadMissing('students');
}
public function mount(Section $section): void
{
$this->section = $section;
$this->section->loadMissing('students');
}
Adrian A
Adrian AOP19h ago
Thanks it worked

Did you find this page helpful?