Created
November 23, 2021 11:58
-
-
Save stephane/822ecd7982c484846af536e991608f27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro field_label(field) -%} | |
<label class="form-label" for="{{ field.id }}"> | |
{{ field.label.text }} {% if field.flags.required %}*{% endif %} | |
</label> | |
{%- endmacro %} | |
{% macro field(field, group_class=None, space_field_class="") -%} | |
<div class="form-group{% if group_class %} {{ group_class}}{% endif %}"> | |
{{ field_label(field) }} | |
{% if field.errors %} | |
{{ field(class="form-control is-invalid" + space_field_class, **kwargs) }} | |
<div class="invalid-feedback">{% for error in field.errors %}{{ error|e }} {% endfor %}</div> | |
{% else %} | |
{{ field(class="form-control" + space_field_class, **kwargs) }} | |
{% endif %} | |
{% if field.description %}<div class="form-text"> {{ field.description }}</div>{% endif %} | |
</div> | |
{%- endmacro %} | |
{% macro show_error_message(error_message) -%} | |
{% if error_message %}<div class="invalid-feedback d-block mb-2">{{ error_message }}</div>{% endif %} | |
{%- endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment