Getting started
Layout component classes can be found in theFilament\Form\Components namespace.
They reside within the schema of your form, alongside any fields.
If youâre using the layout components in a Livewire component, you can put them in the getFormSchema() method:
$form->schema() method:
make() method. Usually, you will then define the child component schema() to display inside:
Columns
You may create multiple columns within each layout component using thecolumns() method:
For more information about creating advanced, responsive column layouts, please see the grid section. All column options in that section are also available in other layout components.
Controlling field column span
You may specify the number of columns that any component may span in the parent grid:columnSpan('full') to ensure that a column spans the full width of the parent grid, however many columns it has:
Setting an ID
You may define an ID for the component using theid() method:
Custom attributes
The HTML of components can be customized even further, by passing an array ofextraAttributes():
Global settings
If you wish to change the default behaviour of a component globally, then you can call the staticconfigureUsing() method inside a service providerâs boot() method, to which you pass a Closure to modify the component using. For example, if you wish to make all card components have 2 columns by default, you can do it like so:
Saving data to relationships
You may load and save the contents of a layout component to aHasOne, BelongsTo or MorphOne Eloquent relationship, using the relationship() method:
title, description and image are automatically loaded from the metadata relationship, and saved again when the form is submitted. If the metadata record does not exist, it is automatically created.
To set this functionality up, you must also follow the instructions set out in the field relationships section. If youâre using the admin panel, you can skip this step.
Grid
Generally, form fields are stacked on top of each other in one column. To change this, you may use a grid component:md breakpoint and higher.
You may pass a different number of columns to the gridâs md breakpoint:
Fieldset
You may want to group fields into a Fieldset. Each fieldset has a label, a border, and a two-column grid by default:columns() method to customize the grid within the fieldset:
Tabs
Some forms can be long and complex. You may want to use tabs to reduce the number of components that are visible at once:activeTab() method:
icon() and badge() methods:
iconPosition() and iconColor() methods:
Wizard
Similar to tabs, you may want to use a multistep form wizard to reduce the number of components that are visible at once. These are especially useful if your form has a definite chronological order, in which you want each step to be validated as the user progresses.We have different setup instructions if youâre looking to add a wizard to an admin panel resource Create page or a table action. Following that documentation will ensure that the ability to submit the form is only available on the last step.Each step has a mandatory label. You may optionally also add a description for extra detail:
submitAction() method to render submit button HTML or a view at the end of the wizard, on the last step. This provides a clearer UX than displaying a submit button below the wizard at all times:
startOnStep() method to load a specific step in the wizard:
skippable() method:
Section
You may want to separate your fields into sections, each with a heading and description. To do this, you can use a section component:columns() method to easily create a grid within the section:
aside() to align heading & description on the left, and the form components inside a card on the right:
collapsible() to optionally hide content in long forms:
collapsed() by default:
Placeholder
Placeholders can be used to render text-only âfieldsâ within your forms. Each placeholder hascontent(), which cannot be changed by the user.
Important: All fields require a unique name. That also applies to Placeholders!
Card
The card component may be used to render the form components inside a card:columns() method to easily create a grid within the card:
Inline labels
You may use theinlineLabel() method to make the form labels and fields in separate columns, inline with each other. It works on all layout components, each field inside will have an inline label.
View
Aside from building custom layout components, you may create âviewâ components which allow you to create custom layouts without extra PHP classes.schema() using the $getChildComponentContainer() closure:
Building custom layout components
You may create your own custom component classes and views, which you can reuse across your project, and even release as a plugin to the community.If youâre just creating a simple custom component to use once, you could instead use a view component to render any custom Blade file.To create a custom column class and view, you may use the following command:
schema() using the $getChildComponentContainer() closure: