© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•8mo ago•
7 replies
Liam

Repeater "Table" with dynamic columns

I'm trying to make a dynamic "table" form using repeaters to add any number of rows and columns. Row headers need to be customisable so the existing
Repeater@table
Repeater@table
doesn't fit the bill. I've tried a few odd things but just trimmed it down to this for an example.

Examples of problems in thread

return $schema->columns(1)->components([
    Hidden::make('columns')->default(2)->live(),

    Section::make('Table Structure')
        ->schema([
            Repeater::make('headers')
                ->label('Table Headers')
                ->simple(
                    TextInput::make('header')
                        ->placeholder('Column header')
                        ->required()
                )
                ->addActionLabel('Add Header')
                ->defaultItems(2)
                ->minItems(2)
                ->addable(false)
                ->deletable(false)
                ->reorderable(false)
                ->grid(fn (Get $get) => $get('../columns')),

            Repeater::make('rows')
                ->label('Table Rows')
                ->simple(
                    Repeater::make('row')
                        ->simple(
                            TextInput::make('cell')
                                ->placeholder('Cell content')
                                ->default('')
                        )
                        ->minItems(1)
                        ->defaultItems(fn (Get $get) => $get('../../columns'))
                        ->addable(false)
                        ->deletable(false)
                        ->reorderable(false)
                        ->grid(fn (Get $get) => $get('../../columns'))
                )
                ->addActionLabel('Add Row')
                ->defaultItems(1)
                ->minItems(1)
                ->collapsed(),
        ]),
    Actions::make([
        Action::make('Add Column')
            ->action(fn (Get $get, Set $set) => $set('columns', $get('columns') + 1)),
    ]),

]);
return $schema->columns(1)->components([
    Hidden::make('columns')->default(2)->live(),

    Section::make('Table Structure')
        ->schema([
            Repeater::make('headers')
                ->label('Table Headers')
                ->simple(
                    TextInput::make('header')
                        ->placeholder('Column header')
                        ->required()
                )
                ->addActionLabel('Add Header')
                ->defaultItems(2)
                ->minItems(2)
                ->addable(false)
                ->deletable(false)
                ->reorderable(false)
                ->grid(fn (Get $get) => $get('../columns')),

            Repeater::make('rows')
                ->label('Table Rows')
                ->simple(
                    Repeater::make('row')
                        ->simple(
                            TextInput::make('cell')
                                ->placeholder('Cell content')
                                ->default('')
                        )
                        ->minItems(1)
                        ->defaultItems(fn (Get $get) => $get('../../columns'))
                        ->addable(false)
                        ->deletable(false)
                        ->reorderable(false)
                        ->grid(fn (Get $get) => $get('../../columns'))
                )
                ->addActionLabel('Add Row')
                ->defaultItems(1)
                ->minItems(1)
                ->collapsed(),
        ]),
    Actions::make([
        Action::make('Add Column')
            ->action(fn (Get $get, Set $set) => $set('columns', $get('columns') + 1)),
    ]),

]);
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

columns dynamic inside table
FilamentFFilament / ❓┊help
3y ago
Dynamic Customise Columns for Table
FilamentFFilament / ❓┊help
2y ago
Add dynamic columns in table
FilamentFFilament / ❓┊help
3y ago
Dynamic Fields in a Repeater Table
FilamentFFilament / ❓┊help
6mo ago