Dropdown Field

Allow the selection of a single option from a drop down of name/value pairs.

Options#

  • Add name/value pairs – Add any number of name/value pairs to be included as options in the drop down field.

  • Set a default – If desired, set which option will be selected when the field is first used.

  • Order – Order the options as desired.


Use#

Template Use#

Access your dropdown fields via the handle you set for the field. Each dropdown field provides an array accessed via dropdownFieldHandle which contains the dropdown options stored in the field, sorted in the order set by the field options.

The loop

{% for dd in entry.yourFieldHandle.dropdownFieldHandle %}

    <p>Name : {{ dd.name }}</p>

    <p>Value : {{ dd.value }}</p>

    <p>Selected? : {{ dd.selected }}</p>

{% endfor %}

Dropdown Properties

  • name - The name of the dropdown option.

  • value - The value of the dropdown option.

  • selected - Whether the dropdown option was selected.

To determine if a particular dropdown option was selected just test the selected property:

{% set firstDD = entry.yourFieldHandle.dropdownFieldHandle[0] %}

{% if firstDD.selected %}

    <p>{{ firstDD.name }} was selected!</p>

{% else %}

    <p>{{ firstDD.name }} was <b>not</b> selected!</p>

{% endif %}