Reputation: 2587
I am looping through some form choice fields in my template, but when I post, the form is not valid as it is missing required field "subnets" however I have manually created the subnet checkboxes. The reason I believe it is failing is because the manually created objects do not have an id, is this right? and how do I assign the id?
template:
{% for value, text in form.subnets.field.choices %}
<div class="checkbox">
<label>
<input type="checkbox" id="subnets" value="{{ value }}" />{{ text }}
</label>
</div>
{% if forloop.counter|divisibleby:4 %}
</div>
<div class="col-xs-3">
{% endif %}
{% endfor %}
error:
subnets
This field is required.
Upvotes: 0
Views: 201
Reputation: 47374
Your checkboxes should have name
attribute:
<input type="checkbox" id="subnets" name="subnets" value="{{ value }}" />{{ text }}
Upvotes: 1