momenoor/filament-table-field
最新稳定版本:v1.0.0
Composer 安装命令:
composer require momenoor/filament-table-field
包简介
Editable table field for Filament Forms with relationship support
README 文档
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
HasManyandBelongsToManyrelationships - 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
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-13