Skip to content

Commit

Permalink
Fix checkbox in forms example.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Mar 5, 2021
1 parent fbf0aa8 commit 671246e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions examples/forms/templates/index.html.tera
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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>

Expand Down
6 changes: 3 additions & 3 deletions examples/forms/templates/macros.html.tera
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
{{ 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) %}
checked
{% endif %}
{% endif %}
>
{{ value }}
{{ label }}
</label>
{% endmacro input %}

Expand Down

0 comments on commit 671246e

Please sign in to comment.