Skip to content

Commit

Permalink
Added support for "required" field flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nCrazed authored and mbr committed Jul 31, 2014
1 parent b471dd0 commit 1c6932b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions flask_bootstrap/templates/bootstrap/wtf.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
form_type="basic",
horizontal_columns=('lg', 2, 10),
button_map={}) %}

{% set required = field.flags.required %}

{% if field.widget.input_type == 'checkbox' %}
{% call _hz_form_wrap(horizontal_columns, form_type, True) %}
<div class="checkbox">
Expand Down Expand Up @@ -75,13 +78,13 @@
<div class="form-group {% if field.errors %} has-error{% endif %}">
{%- if form_type == "inline" %}
{{field.label(class="sr-only")|safe}}
{{field(class="form-control", placeholder=field.description, **kwargs)|safe}}
{{field(class="form-control", placeholder=field.description, required=required, **kwargs)|safe}}
{% elif form_type == "horizontal" %}
{{field.label(class="control-label " + (
" col-%s-%s" % horizontal_columns[0:2]
))|safe}}
<div class=" col-{{horizontal_columns[0]}}-{{horizontal_columns[2]}}">
{{field(class="form-control", **kwargs)|safe}}
{{field(class="form-control", required=required, **kwargs)|safe}}
</div>
{%- if field.errors %}
{%- for error in field.errors %}
Expand All @@ -96,7 +99,7 @@
{%- endif %}
{%- else -%}
{{field.label(class="control-label")|safe}}
{{field(class="form-control", **kwargs)|safe}}
{{field(class="form-control", required=required, **kwargs)|safe}}

{%- if field.errors %}
{%- for error in field.errors %}
Expand Down

0 comments on commit 1c6932b

Please sign in to comment.