Filament Repeater: Five Advanced Use-Cases

Filament 4

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.

example

Get the Source Code:

How it works

Each resource showcases a different capability of the repeater component.

1. Projects → Nested Repeaters with Relationship Mapping

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:

The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.
Get the Source Code: All 154 Premium Examples for $99