Fix checkbox in forms example.

This commit is contained in:
Sergio Benitez 2021-03-04 21:42:26 -08:00
parent fbf0aa824d
commit 671246e90c
2 changed files with 8 additions and 9 deletions

View File

@ -89,13 +89,13 @@
<div class="col">
<label>Applicable Categories</label>
<br />
{{ m::checkbox(name="submission.category", value="Biology") }}
{{ m::checkbox(name="submission.category", label="Biology", value="Biology") }}
<br />
{{ m::checkbox(name="submission.category", value="Chemistry") }}
{{ m::checkbox(name="submission.category", label="Chemistry", value="Chemistry") }}
<br />
{{ m::checkbox(name="submission.category", value="Physics") }}
{{ m::checkbox(name="submission.category", label="Chemistry", value="Physics") }}
<br />
{{ m::checkbox(name="submission.category", value="CS") }}
{{ m::checkbox(name="submission.category", label="CS", value="CS") }}
</div>
</div>
@ -125,8 +125,7 @@
<div class="row">
<div class="col">
{{ m::checkbox(name="submission.ready", value="Submission is
ready for review.") }}
{{ m::checkbox(name="submission.ready", label="Submission is ready for review.") }}
</div>
</div>

View File

@ -25,9 +25,9 @@
{{ self::errors_for(name=name) }}
{% endmacro input %}
{% macro checkbox(name, value) %}
{% macro checkbox(name, label, value="yes") %}
<label {% if name in errors %} class="bd-error" {% endif %}>
<input type="checkbox" name="{{ name }}" value="{{ value }}"
<input type="checkbox" name="{{ name }}" value={{ value }}
{% if name in values %}
{% set field_values = values | get(key=name) %}
{% if field_values is containing(value) %}
@ -35,7 +35,7 @@
{% endif %}
{% endif %}
>
{{ value }}
{{ label }}
</label>
{% endmacro input %}