<p>You could always just use a <a href="http://buildwithcraft.com/docs/table-fields" rel="nofollow noreferrer">Table field</a>, you could then just add a colour to each row, this allows you to give a descriptive name to each colour but also keep the value as the hex or whatever format your colours are in...</p>

<p><a href="https://i.sstatic.net/pm7qe.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pm7qe.jpg" alt="enter image description here"></a></p>

<p>Then its easy to loop like:</p>

<pre><code>{% for option in colorOptions.color %}
   &lt;option value="{{ option.value }}"&gt;{{ option.name }}&lt;/option&gt;
{% endfor %}
</code></pre>

<p>Of course you dont have to have two columns, you could just have the one and loop over the HEX values or whatever, it's totally up to you and how you want to do it. But personally I think the table field is a solid way to go!</p>

CC BY-SA 3.0
2015-09-15T13:55:26.930Z
So obvious now. I was trying to force it with a dropdown, then checkboxes... Thank you!
Damon
CC BY-SA 3.0
2015-09-15T09:08:32.487Z
2015-09-15T09:08:32.487Z
Alec Ritson
<p>I have a registration form that has a dropdown that allows the user to choose a color. This form input will be the same across all pages that allow a user to register.</p>

<p>So, I thought using a Global to populate that dropdown would make sense as the client could manage the color choices. In essence, this is what I'm trying to do:</p>

<pre><code>{% if colorOptions.color | length %}
    &lt;div class="form-group"&gt;
        &lt;label for="colorOption"&gt;Color Option&lt;/label&gt;
        &lt;select id="colorOption" class="form-control"&gt;
            &lt;option value=""&gt; Select&lt;/option&gt;
            {% for option in colorOptions.color %}
                &lt;option value="{{ option }}"&gt;{{ option }}&lt;/option&gt;
            {% endfor %}
        &lt;/select&gt;
    &lt;/div&gt;
{% endif %}
</code></pre>

<p>But I'm struggling with what kind of field type <code>color</code> needs/should/could be within the <code>colorOptions</code> group.</p>

<globals>
How can I populate a dropdown via Globals?
# How can I populate a dropdown via Globals?

(Asked by: username_0 on 2015-09-15)

I have a registration form that has a dropdown that allows the user to choose a color. This form input will be the same across all pages that allow a user to register.
So, I thought using a Global to populate that dropdown would make sense as the client could manage the color choices. In essence, this is what I'm trying to do:
{% if colorOptions.color | length %}
    
        Color Option
        
             Select
            {% for option in colorOptions.color %}
                {{ option }}
            {% endfor %}
        
    
{% endif %}

But I'm struggling with what kind of field type color needs/should/could be within the colorOptions group.

**Tags:** globals


---

## 1 answers

### Answer by username_1 on 2015-09-15. Score: 2 | Accepted answer

You could always just use a Table field, you could then just add a colour to each row, this allows you to give a descriptive name to each colour but also keep the value as the hex or whatever format your colours are in...

Then its easy to loop like:
{% for option in colorOptions.color %}
   {{ option.name }}
{% endfor %}

Of course you dont have to have two columns, you could just have the one and loop over the HEX values or whatever, it's totally up to you and how you want to do it. But personally I think the table field is a solid way to go!

> **Comments:**
> **username_0**: So obvious now. I was trying to force it with a dropdown, then checkboxes... Thank you!  

---

