Rows Field

Illustrated drawing of Amadeus Maxmimilian StadlerIllustrated drawing of Amadeus Maxmimilian Stadler

Amadeus Stadler

Last updated August 28, 2021

The Rows field allows creating dynamic arrangements of fields based on a set of predefined fields. It is well suited for data structures that include arrays of either the same or different objects. A Rows field can also be used to create arrays of types other than string and may thus be an alternative to the Sortable List and Tags fields.

Editing UI Widget

This field is displayed as a list of sub-fields labelled by its label. Depending on its configuration, the sub fields may be collapsed or not and there may or may not be a button to add additional rows to the field.

Output Format

The Rows field outputs either an array of objects or an array of a single type if it only has one type of row and that row is not a Field Group field. If multiple types of row are allowed, each object in the array will have a ___mb_type property holding the key of the sub-field it represents.

Options

The following options are available for this field (default values shown):

{
  "compact": true,
  "allowEditing": true,
  "itemLabel": "Row"
}
  • compact: whether to display the rows in a compact mode or expanded so their nested fields are visible

  • allowEditing: controls whether or not Content Editors may add or remove rows while editing content

  • itemLabel: the label to use in order to refer to a row

Validation

The following validation options are available for this field (default values shown):

{
  "max": null,
  "min": null,
  "unit": "rows"
}

Notes

The Rows field is one of the most powerful fields in Mattrbld because it allows dynamic content. A common use case is to use a Rows field to control the different sections of a website, which might be different from page to page. Instead of defining a Schema for each page, a Rows field could house the sub-schemas for each type of section in the form of Field Group fields, allowing Content Editors to dynamically arrange these building blocks differently for every page.

When the allowEditing option is set to true, a button to add a new row will be shown and once clicked will allow the user to select what type of row to add. These types are generated from each of the Row field’s sub-fields, based on their respective key properties.

Rows fields with a single sub-field can be used to model arrays of types other than string. For example a Rows field with a single Number field as its child will be output as an array of numbers.

Rows fields may be known as “Dynamic Content Zones” or “Block Editors” in other content management systems, since they allow the Content Editor a certain degree of control over the shape of the final data.

Keep in mind that adding fields that are visual only (i.e. have visualOnly set to true), including Container fields, as top-level children is not supported. They will not show up as addable types since they don’t contain content. If you find yourself wanting to add a Container at the top-level of a Rows field, use a Field Group instead.

Version History

  • Version at launch: 1