mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
This macro: - accepts a WTForm form field as a parameter - renders a form field which follows the GOV.UK Elements patterns, both visually and in markup terms It then changes any page which uses either: - the old, non-WTForms macro or - the old, WTFforms `render_field` macro …to use this new macro and removes both of the old ones. It also adds the option to display hint text above the textbox.
22 lines
666 B
HTML
22 lines
666 B
HTML
{% macro textbox(field, hint=False, highlight_tags=False) %}
|
|
<div class="form-group{% if field.errors %} error{% endif %}">
|
|
<label class="form-label" for="{{ field.name }}">
|
|
{{ field.label }}
|
|
{% if hint %}
|
|
<span class="form-hint">
|
|
{{ hint }}
|
|
</span>
|
|
{% endif %}
|
|
{% if field.errors %}
|
|
<span class="error-message">
|
|
{{ field.errors[0] }}
|
|
</span>
|
|
{% endif %}
|
|
</label>
|
|
{{ field(**{
|
|
'class': 'form-control textbox-highlight-textbox' if highlight_tags else 'form-control',
|
|
'data-module': 'highlight-tags' if highlight_tags else ''
|
|
}) }}
|
|
</div>
|
|
{% endmacro %}
|