<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>

CC BY-SA 3.0
2014-08-11T17:50:16.330Z
Where do I find the category id?
AbbeyDesign
CC BY-SA 3.0
2014-08-11T18:03:16.547Z
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.
Victor
CC BY-SA 3.0
2014-08-11T18:10:39.527Z
I had tried using the data-id before I asked. Sorry, should have specified. Form sends, all data is recorded, just not the category.
AbbeyDesign
CC BY-SA 3.0
2014-08-11T18:33:47.127Z
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.
Victor
CC BY-SA 3.0
2014-08-13T13:27:11.620Z
Replaced `name="fieldHandle[]"` with `name="fields[fieldHandle][]"` and Victor's solution worked.
AbbeyDesign
CC BY-SA 3.0
2014-08-13T13:49:10.407Z
@AbbeyDesign Thanks for pointing that out, overlooked that.
Victor
CC BY-SA 3.0
2014-08-11T17:41:33.313Z
2014-08-13T13:48:49.743Z
2014-08-13T13:48:49.743Z
Victor
<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>

<categories><plugins><guest>
Assign Category via Guest Entry Form
# 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 


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 is an array containing category ids, and your form needs to send it that way:


Adding brackets to your field-handle submits the value as an array, 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 Victor's solution worked.  
> **username_1**: @AbbeyDesign Thanks for pointing that out, overlooked that.  

---

