The Legs field

One field type with a mode, because the question an author is really answering is “is this table shared, or is it this entry’s own?” — and the answer should not change which field they have to go and add.

Its own table

In inline mode the grid lives on the element, edited with the same editor the control panel uses. Good for a spec table that belongs to one product and nothing else.

{{ entry.spec.render() }}

Field settings decide how big a new grid starts, and whether authors may change presentation options per entry. Turn that off and every table in the field renders with the same options, leaving the author only the data to think about.

A table from the library

In reference mode the field points at tables in Legs, so one edit updates every place they appear. How many tables decides the shape of the value:

SettingWhat templates get
1The table itself, or null
Anything else (0 = no limit)An ElementCollection, in the order the author arranged them
{# One table #}
{{ entry.priceTable.render() }}

{# Several #}
{% for table in entry.relatedTables %}
  <h2>{{ table.title }}</h2>
  {{ table.render() }}
{% endfor %}

One is not just the default — it changes the value, deliberately. A field that holds one table should read like one table.

Both modes agree

An inline value and a single reference both give you something with .render(), .data and .options, so switching a field between those two modes does not rewrite anybody's templates.

{{ entry.spec.data.rowCount }} rows
{{ entry.spec.render({ compact: true }) }}

Details worth knowing

  • A reference to a table that has since been deleted is dropped, not fatal — you lose that table, not the page.
  • References resolve in the element's own site, so a translated entry points at the translation of the table.
  • Inline cell text is fed to the search index, so searching for a value inside a table finds the entry holding it.
  • The element index shows a size for inline tables and the table's name for references, rather than a wall of cell text.