{% macro render_field(field) %} {% if field.type == 'BooleanField' %} {{ render_boolean_field(field, *args, **kwargs) }} {% elif field.type == 'FileField' %} {{ render_file_field(field, *args, **kwargs) }} {% elif field.type == 'IntegerField' %} {{ render_integer_field(field, *args, **kwargs) }} {% elif field.type == 'MultipleFileField' %} {{ render_multiple_file_field(field, *args, **kwargs) }} {% elif field.type == 'StringField' %} {{ render_string_field(field, *args, **kwargs) }} {% elif field.type == 'SubmitField' %} {{ render_submit_field(field, *args, **kwargs) }} {% elif field.type == 'TextAreaField' %} {{ render_text_area_field(field, *args, **kwargs) }} {% else %} {{ render_generic_field(field, *args, **kwargs) }} {% endif %} {% endmacro %} {% macro render_boolean_field(field) %}
{% endmacro %} {% macro render_file_field(field) %} {% set placeholder = kwargs.pop('placeholder', '') %}
{{ field.label.text }} {{ field(*args, **kwargs) }}
{% for error in field.errors %} {{ error }} {% endfor %}
{% endmacro %} {% macro render_integer_field(field) %} {% set classes = kwargs.pop('class_', '').split(' ') %} {% if 'validate' not in classes %} {% set _ = classes.append('validate') %} {% endif %} {% set _ = kwargs.update({'class_': ' '.join(classes)}) %} {{ render_generic_field(field, *args, **kwargs) }} {% endmacro %} {% macro render_multiple_file_field(field) %} {% set placeholder = kwargs.pop('placeholder', '') %}
{{ field.label.text }} {{ field(*args, **kwargs) }}
{% for error in field.errors %} {{ error }} {% endfor %}
{% endmacro %} {% macro render_string_field(field) %} {% set classes = kwargs.pop('class_', '').split(' ') %} {% if 'validate' not in classes %} {% set _ = classes.append('validate') %} {% endif %} {% set _ = kwargs.update({'class_': ' '.join(classes)}) %} {{ render_generic_field(field, *args, **kwargs) }} {% endmacro %} {% macro render_submit_field(field) %} {% endmacro %} {% macro render_text_area_field(field) %} {% set classes = kwargs.pop('class_', '').split(' ') %} {% if 'materialize-textarea' not in classes %} {% set _ = classes.append('materialize-textarea') %} {% endif %} {% if 'validate' not in classes %} {% set _ = classes.append('validate') %} {% endif %} {% set _ = kwargs.update({'class_': ' '.join(classes)}) %} {{ render_generic_field(field, *args, **kwargs) }} {% endmacro %} {% macro render_generic_field(field) %}
{% if 'material_icon' in kwargs %} {{ kwargs.pop('material_icon') }} {% endif %} {{ field(*args, **kwargs) }} {{ field.label }} {% for error in field.errors %} {{ error }} {% endfor %}
{% endmacro %}