<p>Couple things. First, I believe you need to add an extra set of brackets to the name attribute. The reason being that category fields (as well as all 'related' fieldTypes) store more than one element, even if as in this case there is only one category being assigned. Secondly you'll need to assign the category id as the value.</p>

<pre><code>&lt;select id="language" name="fields[language][]"&gt;
    {% for category in craft.categories.group('languages') %}
         &lt;option value="{{ category.id }}"&gt;{{ category.title }}&lt;/option&gt;
    {% endfor %}
&lt;/select&gt;
</code></pre>

CC BY-SA 3.0
2015-05-20T15:43:02.400Z
no I tried that and it made no difference!
Lettie
CC BY-SA 3.0
2015-05-20T16:13:20.227Z
Sorry. Haven't had coffee yet. I wasn't looking at what you were assigning as the value — you'll want to use the category id for this. I updated the answer.
Douglas McDonald
CC BY-SA 3.0
2015-05-20T16:25:58.897Z
Great! Sorry I missed that the first time.
Douglas McDonald
CC BY-SA 4.0
2022-04-18T20:09:09.650Z
I always forget that second set of []
Mosswalker
CC BY-SA 3.0
2015-05-20T15:28:57.840Z
2015-05-20T16:11:31.187Z
2015-05-20T16:11:31.187Z
Douglas McDonald
<p>I have a frontend form that has a select list for language. This field will allow for one language to be selected. In the backend I have a field set up for my entries as a category field populated by country categories set as required. I can not seem to get the database to update this category field from my frontend form. The select field is set up as follows for the form field handle language.</p>

<pre><code>&lt;select id="language" name="fields[language]"&gt;
    &lt;option value="English"&gt;English&lt;/option&gt;
    etc
&lt;/select&gt;
</code></pre>

<p>Anything I am missing to get this to populate correctly.</p>

<p>Cheers</p>

<entries><categories><form><field><fieldtypes>
How to populate Category field form frontend form?
# How to populate Category field form frontend form?

(Asked by: username_0 on 2015-05-20)

I have a frontend form that has a select list for language. This field will allow for one language to be selected. In the backend I have a field set up for my entries as a category field populated by country categories set as required. I can not seem to get the database to update this category field from my frontend form. The select field is set up as follows for the form field handle language.

    English
    etc


Anything I am missing to get this to populate correctly.
Cheers

**Tags:** entries, categories, form, field, fieldtypes

---

## 1 answers

### Answer by username_1 on 2015-05-20. Score: 5 | Accepted answer

Couple things. First, I believe you need to add an extra set of brackets to the name attribute. The reason being that category fields (as well as all 'related' fieldTypes) store more than one element, even if as in this case there is only one category being assigned. Secondly you'll need to assign the category id as the value.

    {% for category in craft.categories.group('languages') %}
         {{ category.title }}
    {% endfor %}

> **Comments:**
> **username_0**: no I tried that and it made no difference!  
> **username_1**: Sorry. Haven't had coffee yet. I wasn't looking at what you were assigning as the value — you'll want to use the category id for this. I updated the answer.  
> **username_1**: Great! Sorry I missed that the first time.  
> **username_2**: I always forget that second set of []  

---

