{# Forms macros for rendering forms and fields and stuff in templates. #} {% macro hidden_fields(form) -%} {% for field in form.hidden_fields() %} {% endfor %} {%- endmacro %} {% macro row(_field, label=None, help_text=None, width=9, attrs=None) -%}
{% if attrs == None %}{% set attrs = {} %}{% endif %} {% if _field.field.widget.__class__.__name__ == 'CheckboxInput' %} {% else %} {{ field(_field, width=width, attrs=attrs)|trim }} {% endif %} {% for error in _field.errors %}

{{ error }}

{% endfor %} {% if 'inline' in attrs or _field.field.widget.__class__.__name__ != 'CheckboxInput' %} {% if help_text %}

{{ help_text }}

{% elif _field.help_text %}

{{ _field.help_text }}

{% endif %} {% endif %}
{%- endmacro %} {% macro field(_field, attrs=None, width=9) -%} {% set widget = _field.field.widget.__class__.__name__ %} {% set context = _field.field.widget.get_context(_field.html_name, _field.value(), attrs=attrs) %} {% if not 'class' in context['attrs'] and not widget == 'CheckboxInput' %} {% do context['attrs'].update({'class': ('span' ~ width)}) %} {% endif %} {% if 'inline' in context.attrs %}{% do context.attrs.pop('inline') %}{% endif %} {% if widget == 'Textarea' %} {{ _textarea(_field, context) }} {% elif widget == 'Select' %} {{ _select(_field, context) }} {% else %} {{ _input(_field, context) }} {% endif %} {%- endmacro %} {% macro attributes(attrs) -%} {% for name, value in attrs.items() %} {{ name }}{% if value != True %}="{{ value }}"{% endif %}{% endfor %} {%- endmacro %} {% macro _input(_field, context) -%} 0 %} value="{{ context.value }}"{% endif %}> {%- endmacro %} {% macro _textarea(_field, context) -%} {%- endmacro %} {% macro _select(_field, context) -%} {%- endmacro %}