mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-17 04:59:37 -04:00
Refactor radios for reuse
This commit splits up the radio buttons macro into a couple of different macros which can be used independently of each other. This makes this code easier to reuse when implementing custom radio controls.
This commit is contained in:
@@ -5,9 +5,19 @@
|
||||
option_hints={},
|
||||
hide_legend=False
|
||||
) %}
|
||||
{% call radios_wrapper(
|
||||
field, hint, disable, option_hints, hide_legend
|
||||
) %}
|
||||
{% for option in field %}
|
||||
{{ radio(option, disable, option_hints) }}
|
||||
{% endfor %}
|
||||
{% endcall %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro radios_wrapper(field, hint=None, disable=[], option_hints={}, hide_legend=False) %}
|
||||
<div class="form-group {% if field.errors %} form-group-error{% endif %}">
|
||||
<fieldset>
|
||||
<legend class="form-label">
|
||||
<legend class="{{ 'form-label' if not hide_legend else '' }}">
|
||||
{% if hide_legend %}<span class="visually-hidden">{% endif %}
|
||||
{{ field.label.text|safe }}
|
||||
{% if hide_legend %}</span>{% endif %}
|
||||
@@ -17,14 +27,11 @@
|
||||
</span>
|
||||
{% endif %}
|
||||
</legend>
|
||||
{% for option in field %}
|
||||
{{ radio(option, disable, option_hints) }}
|
||||
{% endfor %}
|
||||
{{ caller() }}
|
||||
</fieldset>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro radio(option, disable=[], option_hints={}) %}
|
||||
<div class="multiple-choice">
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user