{% macro render_field(field, with_label=True, with_icon=False, placeholder=False, inputclass=False, divclass=None, class_='') %} {% set kwargs_ = kwargs %} {% if field.type in ('HiddenField', 'DestinationHiddenField') %} {% set with_label=False %} {% endif %} {% if with_label and not placeholder %} {% set placeholder = field.label.text %} {% endif %} {% if not divclass %} {% set divclass = 'col-sm-8' if with_label else 'col-sm-12' %} {% endif %} {%- if field.flags.required %} {% set class_ = class_ + ' required' %} {% do kwargs_.update(required='') %} {% endif %} {% for validator in field.validators %} {% set validator_name = validator.__class__.__name__ %} {% if validator_name == 'Length' %} {% if validator.min != -1 %} {% do kwargs_.update(data_minlength=validator.min) %} {% endif %} {% if validator.max != -1 %} {% do kwargs_.update(maxlength=validator.max) %} {% endif %} {% elif validator_name == 'NumberRange' %} {% if validator.min is not none %} {% do kwargs_.update(min=validator.min) %} {% endif %} {% if validator.max is not none %} {% do kwargs_.update(max=validator.max) %} {% endif %} {% elif validator_name == 'Regexp' %} {% do kwargs_.update(pattern=validator.regex.pattern) %} {% elif validator_name == 'EqualTo' %} {% do kwargs_.update(data_match='#' + validator.fieldname) %} {% do kwargs_.update({'data_match-error': validator.message}) %} {% endif %} {% endfor %} {%- call _wrap_label_input_with_div(field, inputclass, with_label) %} {%- call _wrap_input_with_div(field, divclass, with_icon) %} {%- if field.type == 'BooleanField' %} {{ render_field_boolean(field, class_, **kwargs_) }} {% elif field.type == 'RadioField' %} {{ render_field_radio(field) }} {% elif field.type in ('EmailField', 'FloatField', 'IntegerField', 'PasswordField', 'StringField', 'TextField', 'TextAreaField') %} {{ field(class_=class_+' form-control', placeholder=placeholder, **kwargs_) }} {% elif field.type in ('SelectField', 'SelectMultipleField') %} {{ render_field_select(field, class_, **kwargs_) }} {% elif field.type == 'FieldList' %} {{ render_field_form_list(field, class_=class_) }} {% elif field.type == 'FormField' %} {{ render_field_form(field, class_=class_) }} {% elif field.type == 'DestinationField' or field.type == 'FuncKeyDestinationField' or field.type == 'ApplicationDestinationField' %} {{ render_field_destination(field, class_=class_) }} {% else %} {{ field(class_=class_, placeholder=placeholder, **kwargs_) }} {% endif %} {% if field.errors %}
{{ field.description|safe }}
{% endif %} {%- endcall %} {% endmacro %} {% macro _wrap_label_input_with_div(field, inputclass, with_label) %} {% if field.type in ('SubmitField', 'HiddenField', 'DestinationHiddenField') %} {{ caller() }} {%- else %}