Skip to main content
You are currently viewing the documentation for Filament 1.x, which is a previous version of Filament.Looking for the current stable version? Visit the 5.x documentation.
Filament comes with a powerful form builder which can be used to create intuitive, dynamic, and contextual forms in the admin panel. Forms have a schema, which is an array that contains many form components. The schema defines the form’s fields, their validation rules, and their layout in the form. Here is an example form configuration for a CustomerResource:
Please note: when building forms for resources, please ensure that you are using components within the Filament\Resources\Forms\Components namespace and not Filament\Forms\Components.

Fields

Resource field classes are located in the Filament\Resources\Forms\Components namespace. All field components have access to the following customization methods:

Checkbox

Date Picker

Date-time Picker

File Upload

Please note, it is the responsibility of the developer to delete these files from the disk if they are removed, as Filament is unaware if they are depended on elsewhere. One way to do this automatically is observing a model event.
To customize Livewire’s default file upload validation rules, please refer to its documentation.
Available values for the position methods can be found on Filepond’s website.
Support for multiple file uploads is coming soon.

Key-value

Markdown Editor

Toolbar Buttons

Rich Editor

Toolbar Buttons

Select

If you’re looking to use a select for a belongsTo() relationship, please check out the BelongsToSelect resource field.

Tags Input

Textarea

Text Input

Toggle

The onIcon() and offIcon() methods support the name of any Blade icon component, and passes a set of formatting classes to it. By default, the Blade Heroicons package is installed, so you may use the name of any Heroicon out of the box. However, you may create your own custom icon components or install an alternative library if you wish.

Validation

Filament provides a number of validation methods that can be applied to fields. Please refer to the Laravel Validation docs if you are unsure about any of these.
You may apply additional custom validation rules to any field using the rules() method:
Please note: when specifying resource field names in custom validation rules, you must prefix them with record..

Layout

Grid

By default, form fields are stacked on top of each other in one column. To change this across the entire form, you may chain the columns() method onto the form object:
Alternatively, you may customize the number of columns for a small part of the form using a Grid component:

Section

You may want to separate your fields into sections, each with a heading and subheading. To do this, you can use a Section component:
If you don’t require a subheading, you may use the schema() method to declare the section schema late:
You may use the columns() method to easily create a grid within the section:
Sections may be collapsible() to optionally hide content in long forms:
You may collapse() sections by default:

Fieldset

You may want to group fields into a Fieldset. Each fieldset has a label, a border, and a two-column grid:
You may use the columns() method to customize the number of columns in the fieldset:

Tabs

Some forms can be long and complex. You may want to use tabs to reduce the number that are available at once:
You may use the columns() method to easily create a grid within the tab:

Group

Groups are used to wrap multiple associated form components. They have no effect on the form visually, but are useful for applying modifications to many fields at once:

Placeholder

Placeholders can be used to render text-only “fields” within your forms. Each placeholder has a value, which is cannot be changed by the user.

Dependent Fields

Dependent fields are fields that are modified based on the value of another. For example, you could show a group of fields based on the value of a Select. The first step to setting up dependent fields is to apply the dependable() method to the field that should be watched for changes. When the value of this field is changed, the whole form will reload:
To modify fields based on the value of another, you may use the when() method. The first argument to this method is a callback that evaluates the $record object, and returns true or false depending on if the modifications should be applied. The second argument makes modifications to the current field. If no second argument is supplied, the field will only be shown when the callback in the first argument is true: In this example, the fields in the group will only be shown when the type field is set to individual:
Here, the company_number field will only be required when the type field is set to organization:

Context Customization

You may customize forms based on the page they are used. To do this, you can chain the only() or except() methods onto any form component.
In this example, the name field will only() be displayed on the CreateCustomer page.
In this example, the name field will be required, except() on the EditCustomer page. This is an incredibly powerful pattern, and allows you to completely customize a form contextually by chaining as many methods as you wish to the callback.

Developing Custom Components

To create a custom field, you may use:
This will create a new custom class and view for your field, which you may use in a form in the same way as any other field. To create a generic form component, which may be commonly used for custom layouts, you may generate a class and view using:
Alternatively, simple custom layouts may be created using a View component, and passing the name of a $view in your app: