Introduction
Filament’s Forms package allows you to easily build dynamic, reactive forms in your Laravel applications. It’s used throughout Filament’s ecosystem - in panel resources, action modals, table filters, and more. The form builder provides a fluent API for creating fields, organizing layouts, and handling validation with both frontend and backend support. Learning how to build forms is essential to using Filament effectively. This guide will walk you through the fundamentals of the form builder.How forms work
Forms in Filament are built using a schema-based approach. A schema is an array of components that define the structure and behavior of your form. These components include:- Fields - Input components for capturing data (text inputs, selects, date pickers, etc.)
- Layout components - Components for organizing fields (sections, grids, tabs, etc.)
- Actions - Buttons and interactive elements that can be added to forms
Creating form fields
Form field classes are found in theFilament\Forms\Components namespace. Fields are created using the static make() method, passing the field’s name:
Building a complete form
Here’s an example of a complete form schema with multiple fields:Fluent API pattern
Filament forms use a fluent, chainable API. Each method returns the component instance, allowing you to chain multiple configuration methods:Field labels
By default, field labels are automatically generated from the field name. You can customize the label using thelabel() method:
Field placeholders
Many fields support placeholders that display when the field is empty:Default values
You can set default values for fields that are used when the form is loaded with no data:Disabling fields
Fields can be disabled to prevent user interaction:readOnly():
Helper text and hints
You can add helper text below a field to provide additional context:Autofocus
You can autofocus a field when the form loads:Column spans
When using a grid layout, you can control how many columns a field spans:Field utility injection
Many field methods accept closures that can access various utilities through dependency injection:Accessing other field values
Use theGet utility to access the value of other fields:
Setting other field values
Use theSet utility to modify other fields:
Accessing the current component
Inject the component instance to access its methods:Accessing the Livewire component
Access the parent Livewire component:Available form fields
Filament ships with a comprehensive set of form fields:Text Input
Basic text input field with support for various HTML input types
Select
Dropdown selection with search and multi-select support
Checkbox
Single checkbox for boolean values
Toggle
Modern toggle switch for boolean values
Radio
Radio button group for single selection
Checkbox List
Multiple checkboxes for array selection
Date & Time Pickers
Date, time, and datetime selection
File Upload
File and image upload with preview
Rich Editor
WYSIWYG editor with formatting tools
Markdown Editor
Markdown editor with preview
Repeater
Repeatable set of fields for array data
Builder
Flexible builder with multiple block types
Tags Input
Input for managing tags/keywords
Textarea
Multi-line text input
Key-Value
Key-value pair editor
Color Picker
Color selection input
Toggle Buttons
Button group for single/multiple selection
Slider
Range slider for numeric input
Code Editor
Code editor with syntax highlighting
Hidden
Hidden field for storing data
Next steps
Now that you understand the basics, explore:- Form Fields - Detailed guide to all available fields
- Form Layouts - Organize your forms with sections, grids, and tabs
- Validation - Add validation rules to your fields
- Advanced Features - Reactive fields, dependent fields, and more