Skip to content

JsonGrid Field (PRO)

A grid of repeating rows stored as JSON in the field. Columns are described in the field's configuration.

Settings:

  • column configuration, as JSON

Each column is a name and a header:

json
[
    {"name": "title",  "header": "Title"},
    {"name": "url",    "header": "Link"}
]

For a fixed pair of columns there is a shorter option — KeyValue.

Output:

html
{foreach $items as $item}
    <a href="{$item.url}">{$item.title}</a>
{/foreach}

Do not add an array cast for this field

The value already arrives decoded. Adding 'field' => 'array' to the model's $casts encodes it a second time, and the database ends up with the string "[]" instead of the rows.

Nothing errors — the field simply stops keeping data. If a JsonGrid empties itself on every save, this is why.

© PageBlocks 2019-present