Livewire Form Builder
Published on by Paul Redmond
Filament Form Builder is a package you can use to build forms using the TALL (Tailwind, Alpine.js, Laravel, and Livewire) stack. This means that most of the work to create forms is done through PHP and Livewire components.
Here's a barebones example from the documentation:
<?php namespace App\Http\Livewire; use Filament\Forms;use Illuminate\Contracts\View\View;use Livewire\Component; class EditPost extends Component implements Forms\Contracts\HasForms{ use Forms\Concerns\InteractsWithForms; public Post $post; public $title; public $content; public function mount(): void { $this->form->fill([ 'title' => $this->post->title, 'content' => $this->post->content, ]); } protected function getFormSchema(): array { return [ Forms\Components\TextInput::make('title')->required(), Forms\Components\MarkdownEditor::make('content'), // ... ]; } public function render(): View { return view('edit-post'); }}
The getFormSchema()
method returns an array of fields, which includes a wide variety of field types:
- Text input
- Select
- Multi-select
- Checkbox
- Toggle
- Radio
- Date-time picker
- File upload
- Rich editor
- Markdown editor
- And more...
Fields can also define validation rules for each data point in your form, such as required, unique, exists (in the database), and a bunch more. Here's an example:
Field::make('email')->unique()Field::make('email')->unique(table: \App\Models\User::class)Field::make('email')->unique(column: 'email_address')
You can even make custom validation rules using closures or classes as you can in Laravel. You can use this package as a standalone package with Livewire or as part of the Filament TALL Stack Admin Panel
Head over to the form component documentation to get started. You can view the source code of this package on GitHub.