Entries Field

Allows for the selection of entries.

Options#

  • Restrict to section – Only allow entries from a specific section to be selected.

  • Custom label – A custom label users will see when adding entries to the field. Default is “Add Entry”, the word “Entry” is what will be replaced with your custom label.

  • Limit – How many entries can be selected?

Use#

When a user clicks the “Add Entry” or “Add {your custom label}” button a modal will popup allowing for the selection of an entry. If the restrict selection was set to a specific section then only entries in the section will be made available for selection.

An entry is then selected by clicking on it.

If the field has been set to required then the entry will not be update-able until at least one entry has been selected.

If the field has a limit set, then only that number of entries will be allowed to be selected. Once the limit has been reached the button to add more entries will disappear. If the limit is modified at a later date, and the field contains more than the new limit, an error will be shown notifying the user that they must remove entries from the field to match the new limit.

Template Use#

Access your entries fields via the handle you set for the field. Each entries field provides an array accessed via entryFieldHandle which contains the entries stored in the field, in the order set by the content creators.

{% set entries = entry.yourFieldHandle.entryFieldHandle %}

Each entry in the entryFieldHandle array is an instance of a \Enact\template\wrapper\Entry, which provides properties and method for interfacing with each entry via your twig templates, as well as giving each of your fields a primary real estate as a property using the field handle, hence how you access your fields eg entry.yourFieldHandle.

Examples#

The loop

{% for e in entry.yourFieldHandle.entryFieldHandle %}

    {{ e.getLinkHtml }}

{% endfor %}

Check if the field contains entries

{% if entry.yourFieldHandle.entryFieldHandle | length %}

    {{ entry.yourFieldHandle.entryFieldHandle[0].title }}

{% endif %}

// or test the 0 index of the array

{% if entry.yourFieldHandle.entryFieldHandle[0] %}

    {{ entry.yourFieldHandle.entryFieldHandle[0].url }}

{% endif %}

Basic usage

{% set e = entry.yourFieldHandle.entryFieldHandle[0] %}

{% if e %}

    <a href='{{ e.url }}' >{{ e.title }} - {{ e.createdOn }}</a>

{% endif %}