How do set multiple entry relations using checkboxes on a front end form? I want to set up a form on the front-end of a site to allow logged in users to choose items from a list which represent entries in a channel using checkboxes, then save those entries as relations to an entry that the user is editing.

Using the docs and various questions here I have got setting a relationship to one entry working. However, I want to allow up to 5 relationships to be set and I can't figure out how to add further relationships.

The entry field containing the related choices is called choices.

Here's the template code I've got at the moment (simplified):

{# Get current list of choices to pre-set checkboxes #}
{% set choices = entry.choices %}
{% set choiceList = '' %}

{% for choice in choices %}
    {% set choiceList = choiceList ~ choice.id ~ "," %}
{% endfor %}

&lt;form id="entry-edit-form" method="post" accept-charset="UTF-8"&gt;
    {{ getCsrfInput() }}
    &lt;input type="hidden" name="action" value="entries/saveEntry"&gt;
    &lt;input type="hidden" name="redirect" value="choices-saved"&gt;
    &lt;input type="hidden" name="sectionId" value="8"&gt;
    &lt;input type="hidden" name="enabled" value="1"&gt;
    &lt;input type="hidden" name="entryId" value="{{ entry.id }}"&gt;
    &lt;input type="hidden" id="choicesList" name="fields[choices][]" value=""&gt;

    {% for choice in choices %}
        &lt;div&gt;
            &lt;input class="choice-checkbox" type="checkbox" id="choice{{ loop.index }}" data-id="{{ choice.id }}" {% if choice.id in (choiceList|split(',')) %}checked="checked"{% endif %} /&gt;
            &lt;label for="choice{{ loop.index }}"&gt;{{ choice.title }}&lt;/label&gt;
        &lt;/div&gt;
    {% endfor %}

    &lt;input type="submit" class="button" value="Save choices"&gt;
&lt;/form&gt;


Then I've got some javascript that runs on form submit to loop through the checkboxes and grab the ids of the checked boxes. What format do these need to be saved in as a value to the hidden choicesList field so that an array of related ids is saved to the correct field in the edited entry?

Or is there another, simpler, way of doing this?
I'm pretty sure you can do this much simpler and without javascript. I've setup a front-end form using the doc's example and added checkboxes to choose entries that will be stored in a relational field simply by using name="fields[fieldName][]" in the input type="checkbox". For example:

&lt;input id="" class="" type="checkbox" name="fields[kitIcons][]" value="{{ entry.id }}" checked&gt;{{ entry.title }}&lt;br/&gt;


In the above example, "kitIcons" is the name of my relationship field, and I have this going through a loop to populate the entry.id and entry.title. Seems to be working without any glitches in my system.