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.
Simply put, a Categories field is an array containing category ids, and your form needs to send it that way:
<input type="hidden" name="fields[fieldHandle][]" value="100">
Adding brackets to your field-handle submits the value as an array, and 100
is the id of the category.
{{ 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.
guestEntries.beforeSave
-event and dump-die all the data, to check if it gets send correctly.
name="fieldHandle[]"
with name="fields[fieldHandle][]"
and Victor's solution worked.
Commented
Aug 13, 2014 at 13:27