Field class is the foundation for all form input components in Filament. It extends the base Component class and provides form-specific functionality including validation, labels, hints, and helper text.
Namespace
Inheritance
Extends:Filament\Schemas\Components\Component
Implements: Contracts\HasValidationRules
Static Methods
make()
Create a new field instance.string | null
The field name. This is used for data binding and as the state path. If
null, the field class must define getDefaultName().static
Returns the field instance for method chaining.
getDefaultName()
Get the default name for the field when not explicitly provided.string | null
Returns the default name or
null.Instance Methods
getLabel()
Get the field label.string | Htmlable | null
Returns the field label. If not set, generates a default label from the field name.
getDefaultLabel()
Get the auto-generated default label.string
Returns the label generated from the field name.
aboveLabel()
Add components above the field label.array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render above the label.
static
Returns the field instance for method chaining.
belowLabel()
Add components below the field label.array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render below the label.
static
Returns the field instance for method chaining.
beforeLabel()
Add components before the field label (inline).array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render before the label.
static
Returns the field instance for method chaining.
afterLabel()
Add components after the field label (inline).array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render after the label.
static
Returns the field instance for method chaining.
aboveContent()
Add components above the field content.array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render above the content.
static
Returns the field instance for method chaining.
belowContent()
Add components below the field content.array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render below the content.
static
Returns the field instance for method chaining.
beforeContent()
Add components before the field content (inline).array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render before the content.
static
Returns the field instance for method chaining.
afterContent()
Add components after the field content (inline).array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render after the content.
static
Returns the field instance for method chaining.
aboveErrorMessage()
Add components above validation error messages.array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render above error messages.
static
Returns the field instance for method chaining.
belowErrorMessage()
Add components below validation error messages.array | Schema | Component | Action | ActionGroup | string | Htmlable | Closure | null
Components to render below error messages.
static
Returns the field instance for method chaining.
hasNullableBooleanState()
Check if this field has a nullable boolean state.bool
Returns
true if the field supports nullable boolean values.getDefaultStateCasts()
Get the default state casts for this field.array<StateCast>
Returns an array of state cast instances.
Schema Keys
The Field class defines several schema keys for positioning child components:Traits
The Field class uses multiple traits for additional functionality:CanBeAutofocused- Autofocus supportCanBeMarkedAsRequired- Required field markingCanBeValidated- Validation rulesHasEnum- Enum supportHasExtraFieldWrapperAttributes- Additional wrapper attributesHasHelperText- Helper text below the fieldHasHint- Hint text next to the labelHasLabel- Label configurationHasName- Field name configuration