• Reading time ~ 1 min
  • 08.07.2022

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.

Comments

No comments yet
Sarah 3:34 PM

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

Replies

Sarah 3:34 PM

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

Sarah 3:34 PM

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297