Files
notifications-admin/app/templates/components/textbox.html
Chris Hill-Scott e8fe8c50ba Add a WTForms-compatible textbox macro
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.
2016-01-11 15:20:00 +00:00

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 %}