{% macro render_hidden_errors(form) -%}
{%- if form.errors %}
{%- for fieldname, errors in form.errors.items() %}
{%- if is_hidden_field(form[fieldname]) %}
{%- for error in errors %}
{% endif %}
{% endcall %}
{%- elif field.type == 'RadioField' -%}
{# note: A cleaner solution would be rendering depending on the widget, this is just a hack for now, until I can think of something better #}
{%- elif field.type == 'SubmitField' -%}
{# deal with jinja scoping issues? #}
{% set field_kwargs = kwargs %}
{# note: same issue as above - should check widget, not field type #}
{% call _hz_form_wrap(horizontal_columns, form_type, True, required=required) %}
{% set default_button_style = button_style or template.bootstrap.btn_style %}
{% set default_button_size = button_size or template.bootstrap.btn_size %}
{{ field(class='btn btn-%s btn-%s%s' % (button_map.get(field.name, default_button_style), default_button_size, extra_classes), **field_kwargs) }}
{% endcall %}
{%- elif field.type in ['CSRFTokenField', 'HiddenField'] -%}
{{ field()|safe }}
{%- elif field.type in ['FormField', 'FieldList'] -%}
{# note: FormFields are tricky to get right and complex setups requiring
these are probably beyond the scope of what this macro tries to do.
the code below ensures that things don't break horribly if we run into
one, but does not try too hard to get things pretty. #}
{% else -%}
{% endif %}
{%- endmacro %}
{# valid form types are "basic", "inline" and "horizontal" #}
{% macro render_form(form,
action="",
method="post",
extra_classes=None,
role="form",
form_type="basic",
horizontal_columns=('lg', 2, 10),
enctype=None,
button_map={},
button_style="",
button_size="",
id="",
novalidate=False,
render_kw={}) %}
{#- if any file fields are inside the form and enctype is automatic, adjust if file fields are found. #}
{%- set _enctype = [] %}
{%- if enctype is none %}
{%- for field in form %}
{%- if field.type in ['FileField', 'MultipleFileField'] %}
{#- for loops come with a fairly watertight scope, so this list-hack is used to be able to set values outside of it #}
{%- set _ = _enctype.append('multipart/form-data') %}
{%- endif %}
{%- endfor %}
{%- else %}
{%- set _ = _enctype.append(enctype) %}
{%- endif -%}
{%- endmacro %}
{% macro render_form_row(fields,
row_class='form-row',
col_class_default='col',
col_map={},
button_map={},
button_style='',
button_size='',
form_type='basic',
horizontal_columns=('lg', 2, 10)) %}
{% for field in fields %}
{% if field.name in col_map %}
{% set col_class = col_map[field.name] %}
{% else %}
{% set col_class = col_class_default %}
{% endif %}