{% macro render_field(field) %} {% if field.flags.required and field.type not in ['FileField', 'MultipleFileField'] %} {% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %} {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %} {% else %} {% set tmp = kwargs.update({'class_': 'validate'}) %} {% endif %} {% endif %} {% if field.type == 'BooleanField' %} {{ render_boolean_field(field, *args, **kwargs) }} {% elif field.type == 'DecimalRangeField' %} {{ render_decimal_range_field(field, *args, **kwargs) }} {% elif field.type == 'IntegerField' %} {% set tmp = kwargs.update({'type': 'number'}) %} {% if 'class_' in kwargs and 'validate' not in kwargs['class_'] %} {% set tmp = kwargs.update({'class_': kwargs['class_'] + ' validate'}) %} {% else %} {% set tmp = kwargs.update({'class_': 'validate'}) %} {% endif %} {{ render_generic_field(field, *args, **kwargs) }} {% elif field.type == 'SubmitField' %} {{ render_submit_field(field, *args, **kwargs) }} {% elif field.type in ['FileField', 'MultipleFileField'] %} {{ render_file_field(field, *args, **kwargs) }} {% elif field.type in ['PasswordField', 'SelectField', 'StringField'] %} {{ render_generic_field(field, *args, **kwargs) }} {% endif %} {% endmacro %} {% macro render_boolean_field(field) %} {% set label = kwargs.pop('label', True) %}
{% if 'material_icon' in kwargs %} {{ kwargs.pop('material_icon') }} {% endif %} {% for error in field.errors %} {{ error }} {% endfor %}
{% endmacro %} {% macro render_file_field(field) %} {% set color = kwargs.pop('color', none) %} {% set placeholder = kwargs.pop('placeholder', '') %}
{{ field.label.text }} {{ field(*args, **kwargs) }}
{% endmacro %} {% macro render_generic_field(field) %} {% set label = kwargs.pop('label', True) %}
{% if 'material_icon' in kwargs %} {{ kwargs.pop('material_icon') }} {% endif %} {{ field(*args, **kwargs) }} {% if label %} {{ field.label }} {% endif %} {% for error in field.errors %} {{ error }} {% endfor %}
{% endmacro %} {% macro render_submit_field(field) %} {% set color = kwargs.pop('color', none) %} {% endmacro %} {# maybe create a modal template later on for actions like delete etc #} {# {% macro delete_modal_file(file) %} {% endmacro %} #}