Reputation: 31
As you can see here, I have the code for checkboxes to modify admin permissions. However, the checkboxes aren't being sent to the server even when they are checked. I can't understand why this is happening. Only the hidden input and the csrf_token is being sent when the submit button is clicked.
<tbody>
{% for profile in admins %}
<tr>
<td>{{ profile.player.guid }}</td>
<td>{{ profile.user.username }}</td>
<form method="post">
{% with permissions=profile.admin_permissions_as_list %}
{% csrf_token %}
<input type="hidden" name="action" value="modify,{{ profile.user }}">
<td style="text-align: center"><input class="form-check-input" type="checkbox" value="ban" {% if permissions.0 == '1' %}checked="checked"{% endif %}></td>
<td style="text-align: center"><input class="form-check-input" type="checkbox" value="unban" {% if permissions.1 == '1' %}checked="checked"{% endif %}></td>
<td style="text-align: center"><input class="form-check-input" type="checkbox" value="checkplayers" {% if permissions.2 == '1' %}checked="checked"{% endif %}></td>
<td style="text-align: center"><input class="form-check-input" type="checkbox" value="viewlog" {% if permissions.3 == '1' %}checked="checked"{% endif %}></td>
<td style="text-align: center"><input class="form-check-input" type="checkbox" value="key" {% if permissions.4 == '1' %}checked="checked"{% endif %}></td>
<td style="text-align: center"><input class="form-check-input" type="checkbox" value="faction" {% if permissions.5 == '1' %}checked="checked"{% endif %}></td>
<td><button type="submit" class="btn btn-sm btn-outline-primary">修改权限</button></td>
{% endwith %}
</form>
<td>
<form method="post">
{% csrf_token %}
<input type="hidden" name="action" value="remove,{{ profile.user }}">
<button type="submit" onclick="return confirmRemove('{{ profile.user.username }}');" class="btn btn-sm btn-outline-danger">取消权限</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
Upvotes: 2
Views: 52
Reputation: 943995
You have two major problems.
<td>
(or a child element of a <tr>
)name=value
data if it doesn't have a name (and your checkboxes all lack names)Upvotes: 3