0

I want to output category groups as checkboxes, I've got them outputting correctly however when they are selected and the form is submitted they aren't actually being assigned to the chosen categories suggesting I haven't got them quite right.

here's the code:

{exp:channel:form channel="work" return="contribute/thanks"}
          <p>
            <label for="title">Title</label>
            <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100" onkeyup="liveUrlTitle();">
            <input type="hidden" name="url_title" id="url_title" value="{url_title}" maxlength="75" size="50">
          </p>

          <h2>Formats</h2>
          {categories show_group="4"} {!-- formats --}
            <label class="checkbox">{category_name}
            <input type="checkbox" id="{category_id}" name="{category_id}[]" value="{category_id}">
            </label>
          {/categories}

          <p><input type="submit" name="submit" value="Submit"></p>

{/exp:channel:form}

Any ideas on what i'm doing wrong?

1

You're currently giving them all a different name, so they won't be recognised as the category field.

Try name="category[]" and if that doesn't work, try name="category[data][]"

Also, make sure you add in {selected} to keep the values if it returns in error.

| improve this answer | |
2

I am agree wiht Jammooka u must use name="category[]" as u can see in the document here:

http://www.ellislab.com/expressionengine/user-guide/add-ons/channel/channel_form/index.html#categories

but in your code u must use {checked} instead off {selected} to make it work with your checkboxes .

Regard's.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.