{% macro render_field(field, label_visible=true) -%} {{ field(id=field.id, title=field.description, **kwargs) }} {% if field.errors %} {% for e in field.errors %}

{{ e }}

{% endfor %} {% endif %} {%- endmacro %} {% macro render_stringfield(field) -%}
{% if field.errors %} {% for e in field.errors %}
{{ e }}
{% endfor %} {% endif %}
{%- endmacro %} {% macro render_integerfield(field) -%}
{% if field.errors %} {% for e in field.errors %}
{{ e }}
{% endfor %} {% endif %}
{%- endmacro %} {% macro render_passwordfield(field) -%}
{% if field.errors %} {% for e in field.errors %}
{{ e }}
{% endfor %} {% endif %}
{%- endmacro %} {% macro render_booleanfield(field) -%} {% if field.errors %} {% for e in field.errors %}
{{ e }}
{% endfor %} {% endif %} {%- endmacro %} {% macro render_csrftokenfield(field, kwargs) -%} {{ field(title=field.description, **kwargs) }} {%- endmacro %} {% macro render_selectmultiplefield(field) -%} {% if field.errors %} {% for e in field.errors %}
{{ e }}
{% endfor %} {% endif %} {%- endmacro %} {% macro render_datefield(field) -%}
{% if field.errors %} {% for e in field.errors %}
{{ e }}
{% endfor %} {% endif %}
{%- endmacro %} {% macro render_hiddenfield(field) -%} {% if field.errors %} {% for e in field.errors %}
{{ e }}
{% endfor %} {% endif %} {%- endmacro %} {% macro render_form(form, action_url="", title=None, action_text="Submit", class_="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone", title_class="mdl-card__title", title_text_class="mdl-card__title-text", content_class="mdl-card__supporting-text", action_class="mdl-card__actions", btn_class="mdl-button mdl-js-button mdl-button--raised mdl-button-colored", btn_value="", btn_list=None) -%}

{{ title if title is not none else action_text }}

{% for f in form %} {% if f.type == "StringField" %} {{ render_stringfield(f) }} {% elif f.type == "PasswordField" %} {{ render_passwordfield(f) }} {% elif f.type == "IntegerField" %} {{ render_integerfield(f) }} {% elif f.type == "BooleanField" %} {{ render_booleanfield(f) }} {% elif f.type == "CSRFTokenField" %} {{ render_csrftokenfield(f, kwargs) }} {% elif f.type == "SelectMultipleField" %} {{ render_selectmultiplefield(f) }} {% elif f.type == "DateField" %} {{ render_datefield(f) }} {% elif f.type == "HiddenField" %} {{ render_hiddenfield(f) }} {% else %} {{ f.type }} {{ render_field(f) }} {% endif %} {% endfor %}
{% if btn_list != none %} {%for this_btn_class, action_text, btn_value in btn_list %} {% endfor %} {% else %} {% endif %}
{%- endmacro %}