Fong
Repeater get data from form
I'm new to filament and I want to be able to access the data from the form in the repeater. I have a select in my schema and a repeater. I want to use the data in my select and use it in a query for my repeater. I feel like the answer is very simple but I have been stuck for a while
This is my form:
public static function form(Form $form): Form
{
return $form
->schema([
Select::make('layout_mode')
->options([
'portrait' => 'Portrait',
'landscape' => 'Landscape',
])
->required()
->reactive()
->default('portrait'),
Repeater::make('schedule_data.schedule')
->label('Content Data')
->schema([
Select::make('content_id')
->label('Content')
->required()
->options(function (callable $get) {
return self::getContentOptions($get);
}),
TextInput::make('time')
->label('Display time in seconds')
->numeric(),
])
->columns(2)
->columnSpanFull(),
]);
}
This is the function I use to get the options in my repeater:
protected static function getContentOptions(callable $get): array
{
$layoutMode = $get('layout_mode');
$tenantId = Filament::getTenant()?->id;
if ($tenantId && $layoutMode) {
return Content::where('organization_id', $tenantId)
->where('layout_mode', $layoutMode)
->pluck('name', 'id')
->toArray();
}
return [];
}
How can I pass along the selected value in my select to my repeater?
4 replies