4.2. Common Field Attributes

A number of attributes are valid for all field types:

Table 34. Common field attributes

AttributeDescriptionRequired?
id

The unique id within the current type. This is used to identify content fields when you retrieve content with M2_Content::get().

Yes
multiLingual

0 or 1.

If set to 0, the field will be used across all languages at the site. If set to 1, each language will accept a unique value for the field.

For sites running only one language this is of no importance.

Yes
type

One of the types listed in Section 4.1, “Field Types”.

Yes
searchable

Set to 1 or 0 to determine whether or not the field should be indexed if you choose to let the search app index this content type.

Default value is 1, meaning that all fields are indexed.

No
display

One of:

  • NORMAL

  • HIDDEN: Hidden in the interface. This is useful if you use M2_Content::put() to manage content that should not reveal all data in the administration.

  • STATIC: Will be displayed but can not be edited.

No
linkField

If set to 1, this field is used as the title line for the item in administrative overview lists.

No (one field in your type must be linkField)
toggleWithSelect

Use this attribute to show or hide a field depending on the selection in another field which is a select box.

In this example, the field image will only be visible if useimage has yes selected.

...

  <field id="image" type="image" multiLingual="0" toggleWithSelect="useimage:yes">
    <title lang="en">Image</title>
    <title lang="da">Billede</title>
  </field>

  <field id="useimage" type="select" multiLingual="0">
    <title lang="en">Use image</title>
    <title lang="da">Brug billede</title>

    <options lang="da">
      <option value="yes">Ja</option>
      <option value="no">Nej</option>
    </options>

    <options lang="en">
      <option value="yes">Yes</option>
      <option value="no">No</option>
    </options>
  </field>

...

You can allow several values in the select box trigger the toggleAction. Just separate the values by commas:

...

  <field id="answer" type="select" multiLingual="0">
    <title lang="en">Answer</title>
    <title lang="da">Svar</title>

    <options lang="da">
      <option value="yes">Ja</option>
      <option value="no">Nej (skriv begrundelse herunder)</option>
      <option value="maybe">Måske (skriv begrundelse herunder)</option>
    </options>

    <options lang="en">
      <option value="yes">Yes</option>
      <option value="no">No (supply details below)</option>
      <option value="maybe">Maybe (supply details below)</option>
    </options>
  </field>

  <field id="details" type="textarea" multiLingual="0" toggleWithSelect="answer:no,maybe">
    <title lang="en">Details</title>
    <title lang="da">Begrundelse</title>
  </field>

...
No
toggleWithCheckbox

Works the same way as toggleWithSelect, only that it responds to another field which is presented as checkboxes.

Important

You can not (yet) supply several options for the trigger.

No
toggleAction

Can be either show or hide, and will determine what to do with the field if the toggleWithSelect or toggleWithCheckbox is "true"

No
restrictTo

A comma separated list of groups that this field will be restricted to.

The groups can be represented by ID or developer key.

To make the field restricted to developers, use restrictTo="DEVELOPER". Developers always have access to all fields, but adding this attribute will restrict all non-developers from seeing the field.

All options can be mixed, as in this example:

...

  <field id="secret_key" type="text" multiLingual="0" restrictTo="DEVELOPER,board,420">
    <title lang="da">Hemmelig nøgle</title>
    <title lang="en">Secret Key</title>
  </field>

...

If omitted, all administrators with access to the content type will see the field.

No