Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T15:43:02.400Z
Answers.Text: no I tried that and it made no difference!
Answers.UserDisplayName: Lettie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T16:13:20.227Z
Answers.Text: 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.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T16:25:58.897Z
Answers.Text: Great! Sorry I missed that the first time.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-18T20:09:09.650Z
Answers.Text: I always forget that second set of []
Answers.UserDisplayName: Mosswalker
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T15:28:57.840Z
Answers.LastActivityDate: 2015-05-20T16:11:31.187Z
Answers.LastEditDate: 2015-05-20T16:11:31.187Z
Answers.UserDisplayName: Douglas McDonald
Body: <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>
  
Tags: <entries><categories><form><field><fieldtypes>
Title: How to populate Category field form frontend form?
ThreadText: # 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.
  
  ```
  <select id="language" name="fields[language]">
      <option value="English">English</option>
      etc
  </select>
  
  ```
  
  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.
  
  ```
  <select id="language" name="fields[language][]">
      {% for category in craft.categories.group('languages') %}
           <option value="{{ category.id }}">{{ category.title }}</option>
      {% endfor %}
  </select>
  
  ```
  
  > **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 []  
  
  ---
  
  