This Filament project demonstrates five advanced use-cases for the Filament Repeater field, including nested repeaters, dynamic conditional logic, custom previews, and data transformation techniques.
Each resource showcases a different capability of the repeater component.
This example shows how to create nested repeaters that automatically sync with database relationships. A project has many tasks, and each task has many subtasks. The progress percentage is calculated live based on completed subtasks.
app/Filament/Resources/Projects/Schemas/ProjectForm.php:
Repeater::make('tasks') ->relationship('tasks') ->schema([ Hidden::make('id'), TextInput::make('title') ->required() ->maxLength(255) ->columnSpanFull(), TextInput::make('progress_percent') ->label('Progress') ->suffix('%') ->numeric() ->minValue(0) ->maxValue(100) ->disabled() ->dehydrated(false) ->default(0), Repeater::make('subtasks') ->relationship('subtasks') ->schema([ Hidden::make('id'), TextInput::make('title') ->required() ->maxLength(255) ->live(onBlur: true) ->afterStateUpdated(function (Get $get, Set $set) { static::updateTaskProgress($get, $set); }), Toggle::make('is_done') ->label('Done') ->live(onBlur: true) ->afterStateUpdated(function (Get $get, Set $set) { static::updateTaskProgress($get, $set); }), ]) ->itemLabel(fn (array $state): ?string => $state['title'] ?? null) ->collapsed() ->reorderable() ->addActionLabel('Add Subtask') ->columnSpanFull() ->live() ->afterStateUpdated(function (Get $get, Set $set) { static::updateTaskProgress($get, $set); }), ]) ->itemLabel(fn (array $state): ?string => $state['title'] ?? null) ->collapsed() ->reorderable() ->addActionLabel('Add Task') ->columnSpanFull() ->defaultItems(0),
The key points: