Skip to main content

Module structure

Module structure 

Source
Expand description

Repeaters, groups and flexible content edited as sub-fields, as Filament’s Repeater, Fieldset and Builder: the settings of a repeater or flexible content (RepeaterSettings), the values a form sends for one (structured_input), and the add, delete and move buttons (apply_operation).

The form names each sub-field input after its place, as PHP and Laravel read nested arrays: members[0][name] is the name of the first row of members, seo[title] the title of the group seo, and content[1][data][heading] the heading of the second block of content, whose type is content[1][type]. The panel turns them into the JSON value the field stores, a list of rows or one object, so the checks and the data layer see the same value as when the form sends the field as JSON text.

An error on a sub-field is keyed by its dotted path, as Laravel keys the errors of a nested array: members.0.name, seo.title, content.1.data.heading. The settings path of a block’s sub-field names the block: content.hero.items. A repeater’s settings are keyed by the names of the fields that lead to it, without row numbers: members, or groups.rules for the repeater rules inside each row of groups, as Filament’s state path without the item keys.

Structs§

RepeaterSettings
The settings of a repeater or flexible content field, as Filament’s Repeater and Builder methods. The default allows any number of rows, adds, deletes and moves rows, and labels each row by its number.
Repeaters
The settings of a form’s repeaters and flexible content fields, by path (see the module documentation). A field with no settings has the default ones.

Functions§

apply_operation
form, with the button operation applied to the structured fields of fields, as Filament’s repeater actions change the form’s state without saving it. An operation is add:<path> (a blank row at the end of the repeater at path), add:<path>:<block> (a blank block of flexible content, as Filament’s block picker adds one), delete:<path>.<row>, up:<path>.<row> or down:<path>.<row>. path is the dotted path of the field’s value, such as members or groups.0.rules. An operation that does not apply, or that the field’s settings in repeaters do not allow, changes nothing.
is_structured
Whether a field of kind is edited as sub-fields: a repeater, a group, flexible content or a clone.
structured_input
form, with the value of each structured field of fields built from the sub-field inputs it sent (members[0][name] and so on), as JSON text under the field’s name: a list of rows for a repeater or flexible content, one object for a group or a clone. Rows come in the order of their numbers, numbered again from 0. A field the form sent no sub-field input for keeps what the form sent under its name, such as JSON text, or nothing.
with_hidden_sub_fields
Runs f, a check of a submitted form, with the sub-fields at paths hidden: the dotted paths of their values, as FieldConditions::hidden_sub_fields gives them, such as fields.0.choices. The checks of structured values that f runs on this thread (Field::check_value_in, RegisteredResource::validate_shown and the others) skip those sub-fields, a required one included, and leave them out of the checked value, as a hidden field is not validated or saved in Filament. Paths that are not dotted (the names of top-level fields) are ignored. The panel calls it around a resource’s validation.
without_sub_fields
form without the sub-fields at paths (dotted value paths, such as fields.0.choices or content.0.data.style) in the JSON values of the structured fields of fields, as if the form had not sent them. Paths that are not dotted are ignored.