Skip to main content

Schema-Based Forms

In Filament v4, forms are defined using the Schema class rather than a dedicated Form class. This provides a unified approach for forms, infolists, and other component layouts.

Basic Usage

Schema Class

The Schema class is the foundation for building form layouts in Filament v4.

Namespace

Methods

components()

Define the components in the schema.
array
An array of form field components.
static
Returns the schema instance for method chaining.
Example:

operation()

Set the operation context for the schema.
string
The operation name (e.g., ‘create’, ‘edit’, ‘view’).
static
Returns the schema instance for method chaining.

statePath()

Set the state path for the schema.
string | null
The state path for data binding.
static
Returns the schema instance for method chaining.

columns()

Set the number of columns for the schema layout.
int | array
Number of columns or responsive column configuration.
static
Returns the schema instance for method chaining.
Example:

Form Context

Forms in Filament operate within different contexts:

Operations

  • create - Creating a new record
  • edit - Editing an existing record
  • view - Viewing a record (read-only)
Example:

Form Fields

All form fields extend the Field base class. See the Field API reference for details.

Common Form Components

  • TextInput - Text input field
  • Textarea - Multi-line text area
  • Select - Dropdown select
  • Checkbox - Single checkbox
  • Toggle - Toggle switch
  • Radio - Radio button group
  • DatePicker - Date picker
  • DateTimePicker - Date and time picker
  • FileUpload - File upload
  • RichEditor - Rich text editor
  • MarkdownEditor - Markdown editor
  • ColorPicker - Color picker
  • KeyValue - Key-value pair input
  • Repeater - Repeatable field groups
  • Builder - Flexible content builder

Layout Components

  • Section - Collapsible section
  • Fieldset - Fieldset grouping
  • Grid - Grid layout
  • Tabs - Tabbed interface
  • Wizard - Multi-step wizard
  • Group - Component grouping

Data Binding

Forms automatically bind to Livewire properties using the state path. Example:

Validation

Validation rules are defined on field components. Example:

Form State

Access and modify form state using closures: Example: