Answers.Body: <p>Simply put, a <a href="http://buildwithcraft.com/docs/categories-fields" rel="nofollow">Categories field</a> is an array containing category ids, and your form needs to send it that way:</p>
  
  <pre class="lang-twig prettyprint-override"><code>&lt;input type="hidden" name="fields[fieldHandle][]" value="100"&gt;
  </code></pre>
  
  <p>Adding brackets to your field-handle <a href="http://php.net/manual/en/faq.html.php#faq.html.arrays" rel="nofollow">submits the value as an array</a>, and <code>100</code> is the id of the category.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T17:50:16.330Z
Answers.Text: Where do I find the category id?
Answers.UserDisplayName: AbbeyDesign
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T18:03:16.547Z
Answers.Text: You can either output it in your template: `{{ craft.categories.group('group_handle').slug('some_slug').first.id }}`, or go to "Backend -> Categories" inspect a category, and look for the `data-id` attribute.
Answers.UserDisplayName: Victor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T18:10:39.527Z
Answers.Text: I had tried using the data-id before I asked. Sorry, should have specified. Form sends, all data is recorded, just not the category.
Answers.UserDisplayName: AbbeyDesign
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T18:33:47.127Z
Answers.Text: Try creating a plugin with a [`guestEntries.beforeSave`-event](https://github.com/pixelandtonic/GuestEntries/#the-guestentriesbeforesave-event) and [dump-die](http://php.net/manual/de/function.var-dump.php) all the data, to check if it gets send correctly.
Answers.UserDisplayName: Victor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T13:27:11.620Z
Answers.Text: Replaced `name="fieldHandle[]"` with `name="fields[fieldHandle][]"` and Victor's solution worked.
Answers.UserDisplayName: AbbeyDesign
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T13:49:10.407Z
Answers.Text: @AbbeyDesign Thanks for pointing that out, overlooked that.
Answers.UserDisplayName: Victor
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-11T17:41:33.313Z
Answers.LastActivityDate: 2014-08-13T13:48:49.743Z
Answers.LastEditDate: 2014-08-13T13:48:49.743Z
Answers.UserDisplayName: Victor
Body: <p>Is is possible to assign a category via a frontend Guest Entry form.</p>
  
  <p>I tried </p>
  
  <pre><code>&lt;input type="hidden" name="fieldHandle" value="SomeExistingCategorySlug"&gt;
  </code></pre>
  
  <p>But that did not work.</p>
  
Tags: <categories><plugins><guest>
Title: Assign Category via Guest Entry Form
ThreadText: # Assign Category via Guest Entry Form
  
  (Asked by: username_0 on 2014-08-11)
  
  Is is possible to assign a category via a frontend Guest Entry form.
  
  I tried
  
  ```
  <input type="hidden" name="fieldHandle" value="SomeExistingCategorySlug">
  
  ```
  
  But that did not work.
  
  **Tags:** categories, plugins, guest
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-08-11. Score: 6 | Accepted answer
  
  Simply put, a [Categories field](http://buildwithcraft.com/docs/categories-fields) is an array containing category ids, and your form needs to send it that way:
  
  ```twig
  <input type="hidden" name="fields[fieldHandle][]" value="100">
  
  ```
  
  Adding brackets to your field-handle [submits the value as an array](http://php.net/manual/en/faq.html.php#faq.html.arrays), and `100` is the id of the category.
  
  > **Comments:**
  > **username_0**: Where do I find the category id?  
  > **username_1**: You can either output it in your template: `{{ craft.categories.group('group_handle').slug('some_slug').first.id }}`, or go to "Backend -> Categories" inspect a category, and look for the `data-id` attribute.  
  > **username_0**: I had tried using the data-id before I asked. Sorry, should have specified. Form sends, all data is recorded, just not the category.  
  > **username_1**: Try creating a plugin with a [`guestEntries.beforeSave`-event](https://github.com/pixelandtonic/GuestEntries/#the-guestentriesbeforesave-event) and [dump-die](http://php.net/manual/de/function.var-dump.php) all the data, to check if it gets send correctly.  
  > **username_0**: Replaced `name="fieldHandle[]"` with `name="fields[fieldHandle][]"` and username_1's solution worked.  
  > **username_1**: @username_0 Thanks for pointing that out, overlooked that.  
  
  ---
  
  