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

View File

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