momenoor / filament-table-field
Editable table field for Filament Forms with relationship support
v1.0.0
2025-04-13 12:47 UTC
Requires
- php: ^8.1
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
README
Filament Table Field
A powerful custom Laravel Filament form field that renders an interactive table to manage related records via HasMany
or BelongsToMany
relationships — directly within your form.
Built for Filament v3 — no Blade components needed.
🚀 Features
- Inline editable table using Filament Tables API
- Modal-based Create/Edit/Delete actions
- Supports
HasMany
andBelongsToMany
relationships - Auto-syncs records after form submission
- Dynamic form schema and column config
- Lifecycle hooks:
beforeCreateRecord()
beforeUpdateRecord()
- Auto-injection of parent form data
- Configurable header actions and table display options
- Customizable empty state
📦 Installation
composer require momenoor/filament-table-field
Register the plugin (if not auto-discovered):
\Momenoor\FilamentTableField\FilamentTableFieldServiceProvider::class,
🔧 Usage
use Momenoor\FilamentTableField\Forms\Components\TableField; TableField::make('tasks') ->relationship('tasks') ->tableColumns([ TextColumn::make('name'), TextColumn::make('status')->badge(), ]) ->createFormSchema([ TextInput::make('name')->required(), Select::make('status')->options([ 'new' => 'New', 'in_progress' => 'In Progress', 'done' => 'Done', ])->required(), ]) ->beforeCreateRecord(fn ($parentState) => [ 'client_id' => $parentState['client_id'] ?? null, ]) ->beforeUpdateRecord(fn ($record) => [ 'updated_by' => auth()->id(), ]) ->heading('Task Assignments') ->defaultRecordDefaults([ 'status' => 'new' ]) ->disableEdit(false) ->disableDelete(false);
⚙ API Reference
Method | Description |
---|---|
relationship() |
Set the Eloquent relationship name |
tableColumns() |
Define table columns (Filament Columns ) |
createFormSchema() |
Define modal form schema for create/edit |
defaultRecordDefaults() |
Default values merged with form submission |
beforeCreateRecord() |
Hook for modifying data before creating a record |
beforeUpdateRecord() |
Hook for modifying data before updating a record |
disableCreate() |
Disable the Create action |
disableEdit() |
Disable the Edit action |
disableDelete() |
Disable the Delete action |
heading() |
Set table heading title |
Hooks receive:
data
: submitted form data for that rowparentState
: full parent form statestate
: current field staterecord
: the parent model being editedfield
: the TableField instance
📚 License
MIT © Momen Noor