Schema-Based Forms
In Filament v4, forms are defined using theSchema class rather than a dedicated Form class. This provides a unified approach for forms, infolists, and other component layouts.
Basic Usage
Schema Class
TheSchema class is the foundation for building form layouts in Filament v4.
Namespace
Methods
components()
Define the components in the schema.An array of form field components.
Returns the schema instance for method chaining.
operation()
Set the operation context for the schema.The operation name (e.g., ‘create’, ‘edit’, ‘view’).
Returns the schema instance for method chaining.
statePath()
Set the state path for the schema.The state path for data binding.
Returns the schema instance for method chaining.
columns()
Set the number of columns for the schema layout.Number of columns or responsive column configuration.
Returns the schema instance for method chaining.
Form Context
Forms in Filament operate within different contexts:Operations
create- Creating a new recordedit- Editing an existing recordview- Viewing a record (read-only)
Form Fields
All form fields extend theField base class. See the Field API reference for details.
Common Form Components
TextInput- Text input fieldTextarea- Multi-line text areaSelect- Dropdown selectCheckbox- Single checkboxToggle- Toggle switchRadio- Radio button groupDatePicker- Date pickerDateTimePicker- Date and time pickerFileUpload- File uploadRichEditor- Rich text editorMarkdownEditor- Markdown editorColorPicker- Color pickerKeyValue- Key-value pair inputRepeater- Repeatable field groupsBuilder- Flexible content builder
Layout Components
Section- Collapsible sectionFieldset- Fieldset groupingGrid- Grid layoutTabs- Tabbed interfaceWizard- Multi-step wizardGroup- Component grouping