Skip to main content

Module layout

Module layout 

Source
Expand description

The layout of a resource’s form, as Filament’s layout components: a grid of columns, Sections that group fields under a heading, Groups that stack sections in one column, each with a column_span, and Tabs that show one Tab of fields at a time.

A WordPress-like post editor puts the content in a main column two thirds wide and the publishing settings in a sidebar column one third wide, as a Filament form does with ->columns(3) and a Group of sections with ->columnSpan(2) beside one with ->columnSpan(1):

use ignite_core::{FormLayout, Group, Section};

let layout = FormLayout::new().columns(3).schema([
    Group::make([Section::make("Content").schema(["title", "slug", "body"])]).column_span(2),
    Group::make([
        Section::make("Publish").schema(["status", "published_at"]),
        Section::make("Category").schema(["category"]),
    ])
    .column_span(1),
]);
assert_eq!(layout.column_count(), Some(3));

As in Filament, columns and column_span apply from the lg breakpoint; on a smaller screen every component takes the full width, one under the other. A form without a layout (the default, FormLayout::new) renders as before: one card of fields. A field the layout does not place is shown after the others, in the first column, so a form never loses a field it saves.

Structs§

FormLayout
The layout of a resource’s create and edit forms: the grid’s columns, the components in it, and the page’s content width. See the module documentation.
Group
Sections and fields stacked one under the other in one column of the form, as Filament’s Group: a sidebar is a group of sections.
Section
Fields under a heading, shown as one card, as Filament’s Section.
Tab
One tab of Tabs, as Filament’s Tabs\Tab: a label and its fields and sections. It is not re-exported at the crate root, where Tab is a list page’s tab; write ignite_core::layout::Tab.
Tabs
Tabs, as Filament’s Tabs schema component: one card whose tab list shows one Tab of fields at a time. The first tab is open when the form shows, as in Filament, unless active_tab names another. Every tab’s fields are in the form, so a save sends them all, whichever tab is open.

Enums§

ColumnSpan
How many grid columns a component takes, as Filament’s columnSpan().
Component
One part of a form layout: a field by name, a Section, a Group or Tabs.
Width
The widest the page’s content may be, as Filament’s getMaxContentWidth() and its Width enum. The panel’s default is ScreenTwoExtraLarge.