{# Renders field for bootstrap 3 standards. Params: field - WTForm field kwargs - pass any arguments you want in order to put them into the html attributes. There are few exceptions: for - for_, class - class_, class__ - class_ Example usage: {{ macros.render_field(form.email, placeholder='Input email', type='email') }} #} {% macro render_field(field, label_visible=true) -%}
{% if (field.type != 'HiddenField' and field.type !='CSRFTokenField') and label_visible %} {% endif %} {{ field(class_='form-control', **kwargs) }} {% if field.errors %} {% for e in field.errors %}

{{ e }}

{% endfor %} {% endif %}
{%- endmacro %} {# Renders checkbox fields since they are represented differently in bootstrap Params: field - WTForm field (there are no check, but you should put here only BooleanField. kwargs - pass any arguments you want in order to put them into the html attributes. There are few exceptions: for - for_, class - class_, class__ - class_ Example usage: {{ macros.render_checkbox_field(form.remember_me) }} #} {% macro render_checkbox_field(field) -%}
{%- endmacro %} {# Renders radio field Params: field - WTForm field (there are no check, but you should put here only BooleanField. kwargs - pass any arguments you want in order to put them into the html attributes. There are few exceptions: for - for_, class - class_, class__ - class_ Example usage: {{ macros.render_radio_field(form.answers) }} #} {% macro render_radio_field(field) -%} {% for value, label, _ in field.iter_choices() %}
{% endfor %} {%- endmacro %} {# Render a single condition #} {% macro render_condition(condition) -%} {% if condition.name %}
  • {% else %}
  • {% endif %}
    {{ render_field(condition.argument, label_visible=False) }}
    {{ render_field(condition.negative, label_visible=False) }}
    {{ render_field(condition.operator, label_visible=False) }}
    {{ render_field(condition.operator_arguments[0], label_visible=False) }}
    {{ render_field(condition.operator_arguments[1], label_visible=False) }}
  • {%- endmacro %} {# Render an entire switch #} {% macro render_switch(switch, deletable=True, collapse=True, new=False) -%}

    {% if collapse %} {% endif %} {{ switch.name.data }}

    {{ render_field(switch.name, readonly=not new, placeholder='A unique switch name.') }} {{ render_field(switch.label, placeholder='A label -- useful for grouping switches.') }} {{ render_field(switch.description, placeholder='A text description of this switch.') }} {{ render_field(switch.state, placeholder='A text description of this switch.') }} {{ render_checkbox_field(switch.compounded) }} {{ render_checkbox_field(switch.concent) }} {{ switch.delete }} {% if new %} {{ render_field(switch.is_new, value='new') }} {% endif %}
    {% if deletable %} {% endif %}

    {%- endmacro %}