This is a package for Filament form component. Extends from Repeater, but display in Table Layout.
You can install the package via composer:
composer require icetalker/filament-table-repeater
You can publish the views using
php artisan vendor:publish --tag="filament-table-repeater"
use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater;
protected function form(Form $form): Form
{
return $form->schema([
...
TableRepeater::make('items')
->relationship('items')
->schema([
Forms\Components\TextInput::make('product'),
...
])
->reorderable()
->cloneable()
->collapsible()
->minItems(3)
->maxItems(5),
]);
}
Since this component extends from
Filament\Forms\Components\Repeater
, you can use most of its methods, except for a few methods likeinset()
,grid()
,columns()
.
To customize styles for each cell, you can pass an array of component name as key and css style as value to colStyles()
. See example below:
use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater;
protected function form(Form $form): Form
{
return $form->schema([
...
TableRepeater::make('items')
->relationship('items')
->schema([
Forms\Components\TextInput::make('product'),
Forms\Components\TextInput::make('quantity'),
...
])
->colStyles([
'product' => 'color: #0000ff; width: 250px;',
]),
]);
}
Besides, you can also pass a callback function to colStyles()
. This may unlock more customization possibilities. See example below:
use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater;
protected function form(Form $form): Form
{
return $form
->schema([
...
Forms\Components\Grid::make(1)->schema([
TableRepeater::make('items')
->relationship('items')
->schema([
Forms\Components\TextInput::make('product'),
Forms\Components\TextInput::make('quantity'),
...
])
->colStyles(function(){
return [
'product' => 'color: #0000ff; width: 250px;',
]
}),
]),
]);
}
Since Filament v4, Reapeater
Component has it own table()
method. You could use it to achieve the same function if you are using the latest version.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.