<pre><code>{% for option in entry.dropdownFieldHandle.options %}
    &lt;li&gt;{{ option }}&lt;/li&gt;
{% endfor %}
</code></pre>

<p>That should be it :)</p>

<pre><code>{% for entry in craft.entries.section('sectionname') %}
  {% for option in entry.dropdownFieldHandle.options %}
    &lt;li&gt;{{ option }}&lt;/li&gt;
  {% endfor %}
{% endfor %}
</code></pre>

<p>Use the above if it is only one page</p>

<pre><code>{% set myArray = [] %}

{% for entry in craft.entries.section('sectionname') %}
  {% for option in entry.dropdownFieldHandle.options %}
        {% set value = option %}

        {% set myArray = myArray|merge([value]) %}
  {% endfor %}
{% endfor %}
</code></pre>

<p>And loop over that variable , better to load 1 variable as array if you need it over multiple pages. Just make sure all pages have access to this variable (or create a macro for it)</p>

CC BY-SA 3.0
2016-11-07T14:33:18.663Z
also if you want the fields in general use the following:

`{% set dropdown = craft.fields.getFieldByHandle('season') %}

{% for option in dropdown.options %}
 {{ option }}
{% endif %}`
mike-orez
CC BY-SA 3.0
2016-11-07T15:01:05.990Z
I'd guess you meant the last `{% endif %}` to be a `{% endfor %}`, but even then craft gives me the error that there is no scope called "options".
justussimon91
CC BY-SA 3.0
2016-11-07T15:36:47.127Z
I edited my answers, one of the solutions should work.
mike-orez
CC BY-SA 3.0
2016-11-08T07:37:37.677Z
Your first code snipped does not produce any output at all for me. The second does, but outputs every season as often as there are entries in the section I chose for `'sectionname'` instead of just once as required. Still appreciated :)
justussimon91
CC BY-SA 3.0
2016-11-08T07:48:38.183Z
I got it solved by just limiting the `for entry in craft.entries.section('sectionname')` to 1 by appending `.limit(1)`
justussimon91
CC BY-SA 3.0
2016-11-07T14:30:11.010Z
2016-11-07T15:36:20.203Z
2016-11-07T15:36:20.203Z
mike-orez
<p>I'm currently trying to create a for-loop that loops through all options of a dropdown field created in Craft.</p>

<p>I have a field called "Season", with the possible options to choose from being "2015/16" and "2016/17". What I'm trying to do now is to create a loop that would loop as many times as there are options available in that field.</p>

<p>I'm thinking of something like this:  </p>

<pre><code>{% for option in fields.season %}
    ...code...
{% endfor %}`
</code></pre>

<p>Is there a way to accomplish this within Craft?</p>

<field><forloop><loop>
Loop through all possible options of a Dropdown-field
# Loop through all possible options of a Dropdown-field

(Asked by: username_0 on 2016-11-07)

I'm currently trying to create a for-loop that loops through all options of a dropdown field created in Craft.
I have a field called "Season", with the possible options to choose from being "2015/16" and "2016/17". What I'm trying to do now is to create a loop that would loop as many times as there are options available in that field.
I'm thinking of something like this:  
{% for option in fields.season %}
    ...code...
{% endfor %}`

Is there a way to accomplish this within Craft?

**Tags:** field, forloop, loop


---

## 1 answers

### Answer by username_1 on 2016-11-07. Score: 2 | Accepted answer

{% for option in entry.dropdownFieldHandle.options %}
    {{ option }}
{% endfor %}

That should be it :)
{% for entry in craft.entries.section('sectionname') %}
  {% for option in entry.dropdownFieldHandle.options %}
    {{ option }}
  {% endfor %}
{% endfor %}

Use the above if it is only one page
{% set myArray = [] %}

{% for entry in craft.entries.section('sectionname') %}
  {% for option in entry.dropdownFieldHandle.options %}
        {% set value = option %}

        {% set myArray = myArray|merge([value]) %}
  {% endfor %}
{% endfor %}

And loop over that variable , better to load 1 variable as array if you need it over multiple pages. Just make sure all pages have access to this variable (or create a macro for it)

> **Comments:**
> **username_1**: also if you want the fields in general use the following:  `{% set dropdown = craft.fields.getFieldByHandle('season') %}  {% for option in dropdown.options %}  {{ option }} {% endif %}`  
> **username_0**: I'd guess you meant the last `{% endif %}` to be a `{% endfor %}`, but even then craft gives me the error that there is no scope called "options".  
> **username_1**: I edited my answers, one of the solutions should work.  
> **username_0**: Your first code snipped does not produce any output at all for me. The second does, but outputs every season as often as there are entries in the section I chose for `'sectionname'` instead of just once as required. Still appreciated :)  
> **username_0**: I got it solved by just limiting the `for entry in craft.entries.section('sectionname')` to 1 by appending `.limit(1)`  

---

