17 lines
539 B
HTML
17 lines
539 B
HTML
{#
|
|
From: https://wtforms.readthedocs.io/en/2.3.x/specific_problems/#rendering-errors
|
|
Usage: with_errors(form.field, style='font-weight: bold')
|
|
#}
|
|
|
|
{% macro with_errors(field) %}
|
|
<div class="form_field">
|
|
{% if field.errors %}
|
|
{% set css_class = 'has_error ' + kwargs.pop('class', '') %}
|
|
{{ field(class=css_class, **kwargs) }}
|
|
<ul class="errors">{% for error in field.errors %}<li>{{ error|e }}</li>{% endfor %}</ul>
|
|
{% else %}
|
|
{{ field(**kwargs) }}
|
|
{% endif %}
|
|
</div>
|
|
{% endmacro %}
|