Layouts
Overview
Layouts arrange fields into grids, sections, tabs and wizards, without adding to the form's data.
A layout holds other components. It decides how they sit on the page, and it doesn't change the form's state.
use Xelqun\Forms\Components\TextInput;
use Xelqun\Forms\Layouts\Section;
Section::make('Contact')
->columns(2)
->schema([
TextInput::make('name'),
TextInput::make('email'),
]);
| Layout | Use it for |
|---|---|
| Grid, Flex, Group, FusedGroup | Columns and rows |
| Section, Fieldset | Headed groups of fields |
| Tabs | Fields on separate tabs |
| Wizard | Steps, checked one at a time |
| Callout, EmptyState | Messages in a form |
| Text, Icon, Image, UnorderedList | Plain content |
| Actions | Buttons in a form |
Columns
columns() takes a number, or an array by breakpoint. A number means one column on small screens.
Section::make('Address')->columns(['md' => 2, 'xl' => 4])->schema([...]);
Conditions
Layouts take the same visibility rules as fields, so a whole section can follow a condition.
use Xelqun\Forms\Conditions\When;
use Xelqun\Forms\Layouts\Fieldset;
Fieldset::make('Shipping address')
->visibleWhen(When::eq('ship_elsewhere', true))
->schema([...]);
A hidden layout's fields are left out of validation and of the saved data.