2016-06-29 17:10:49 +01:00
|
|
|
{% macro radios(
|
|
|
|
|
field,
|
2016-11-01 15:34:04 +00:00
|
|
|
hint=None,
|
|
|
|
|
disable=[],
|
2017-11-20 16:30:51 +00:00
|
|
|
option_hints={},
|
|
|
|
|
hide_legend=False
|
2016-06-29 17:10:49 +01:00
|
|
|
) %}
|
2018-06-12 13:17:45 +01:00
|
|
|
{% call radios_wrapper(
|
|
|
|
|
field, hint, disable, option_hints, hide_legend
|
|
|
|
|
) %}
|
|
|
|
|
{% for option in field %}
|
|
|
|
|
{{ radio(option, disable, option_hints) }}
|
|
|
|
|
{% endfor %}
|
|
|
|
|
{% endcall %}
|
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
2018-12-18 14:40:53 +00:00
|
|
|
|
|
|
|
|
{% macro radio_list(
|
|
|
|
|
options,
|
|
|
|
|
child_map,
|
|
|
|
|
disable=[],
|
2019-01-04 13:44:52 +00:00
|
|
|
option_hints={}
|
2018-12-18 14:40:53 +00:00
|
|
|
) %}
|
2019-01-04 13:44:52 +00:00
|
|
|
<ul>
|
2018-12-18 14:40:53 +00:00
|
|
|
{% for option in options %}
|
|
|
|
|
{% if child_map[option.data] %}
|
|
|
|
|
{% call radio(option, disable, option_hints, as_list_item=True) %}
|
|
|
|
|
{{ radio_list(child_map[option.data], child_map, disable, option_hints) }}
|
|
|
|
|
{% endcall %}
|
|
|
|
|
{% else %}
|
|
|
|
|
{{ radio(option, disable, option_hints, as_list_item=True) }}
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</ul>
|
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% macro radios_nested(
|
|
|
|
|
field,
|
|
|
|
|
child_map,
|
|
|
|
|
hint=None,
|
|
|
|
|
disable=[],
|
|
|
|
|
option_hints={},
|
|
|
|
|
hide_legend=False
|
|
|
|
|
) %}
|
|
|
|
|
{% call radios_wrapper(
|
|
|
|
|
field, hint, disable, option_hints, hide_legend
|
|
|
|
|
) %}
|
2019-01-04 13:44:52 +00:00
|
|
|
<div class="radios-nested">
|
|
|
|
|
{{ radio_list(child_map[None], child_map, disable, option_hints) }}
|
|
|
|
|
</div>
|
2018-12-18 14:40:53 +00:00
|
|
|
{% endcall %}
|
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
2018-06-12 13:17:45 +01:00
|
|
|
{% macro radios_wrapper(field, hint=None, disable=[], option_hints={}, hide_legend=False) %}
|
2017-04-10 11:16:22 +01:00
|
|
|
<div class="form-group {% if field.errors %} form-group-error{% endif %}">
|
2016-06-29 17:10:49 +01:00
|
|
|
<fieldset>
|
2018-06-12 13:17:45 +01:00
|
|
|
<legend class="{{ 'form-label' if not hide_legend else '' }}">
|
2017-11-20 16:30:51 +00:00
|
|
|
{% if hide_legend %}<span class="visually-hidden">{% endif %}
|
|
|
|
|
{{ field.label.text|safe }}
|
|
|
|
|
{% if hide_legend %}</span>{% endif %}
|
2018-08-30 11:51:34 +01:00
|
|
|
{% if hint %}
|
|
|
|
|
<span class="form-hint">
|
|
|
|
|
{{ hint }}
|
|
|
|
|
</span>
|
|
|
|
|
{% endif %}
|
2016-06-29 17:10:49 +01:00
|
|
|
{% if field.errors %}
|
2017-10-16 14:58:08 +01:00
|
|
|
<span class="error-message" data-module="track-error" data-error-type="{{ field.errors[0] }}" data-error-label="{{ field.name }}">
|
2016-06-29 17:10:49 +01:00
|
|
|
{{ field.errors[0] }}
|
|
|
|
|
</span>
|
|
|
|
|
{% endif %}
|
|
|
|
|
</legend>
|
2018-06-12 13:17:45 +01:00
|
|
|
{{ caller() }}
|
2016-06-29 17:10:49 +01:00
|
|
|
</fieldset>
|
|
|
|
|
</div>
|
|
|
|
|
{% endmacro %}
|
2016-08-08 10:28:40 +01:00
|
|
|
|
2018-12-18 14:40:53 +00:00
|
|
|
{% macro radio(option, disable=[], option_hints={}, data_target=None, as_list_item=False) %}
|
|
|
|
|
{% if as_list_item %}
|
|
|
|
|
<li class="multiple-choice" {% if data_target %}data-target="{{ data_target }}"{% endif %}>
|
|
|
|
|
{% else %}
|
2018-08-09 11:59:05 +01:00
|
|
|
<div class="multiple-choice" {% if data_target %}data-target="{{ data_target }}"{% endif %}>
|
2018-12-18 14:40:53 +00:00
|
|
|
{% endif %}
|
2018-05-18 14:05:48 +01:00
|
|
|
<input
|
|
|
|
|
id="{{ option.id }}" name="{{ option.name }}" type="radio" value="{{ option.data }}"
|
|
|
|
|
{% if option.data in disable %}
|
|
|
|
|
disabled
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% if option.checked %}
|
|
|
|
|
checked
|
|
|
|
|
{% endif %}
|
|
|
|
|
>
|
|
|
|
|
<label class="block-label" for="{{ option.id }}">
|
|
|
|
|
{{ option.label.text }}
|
|
|
|
|
{% if option_hints[option.data] %}
|
|
|
|
|
<div class="block-label-hint">
|
|
|
|
|
{{ option_hints[option.data] }}
|
|
|
|
|
</div>
|
|
|
|
|
{% endif %}
|
|
|
|
|
</label>
|
2018-12-18 14:40:53 +00:00
|
|
|
{% if caller %}
|
|
|
|
|
{{ caller() }}
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% if as_list_item %}
|
|
|
|
|
</li>
|
|
|
|
|
{% else %}
|
2018-05-18 14:05:48 +01:00
|
|
|
</div>
|
2018-12-18 14:40:53 +00:00
|
|
|
{% endif %}
|
2018-05-18 14:05:48 +01:00
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
|
|
|
2016-08-07 09:17:49 +01:00
|
|
|
{% macro radio_select(
|
|
|
|
|
field,
|
|
|
|
|
hint=None,
|
|
|
|
|
wrapping_class='form-group'
|
|
|
|
|
) %}
|
2017-04-10 11:16:22 +01:00
|
|
|
<div class="{{ wrapping_class }} {% if field.errors %} form-group-error{% endif %}">
|
2016-08-07 09:17:49 +01:00
|
|
|
<fieldset>
|
|
|
|
|
<legend class="form-label">
|
2017-02-13 09:50:26 +00:00
|
|
|
{{ field.label.text }}
|
2016-08-07 09:17:49 +01:00
|
|
|
{% if field.errors %}
|
2017-10-16 14:58:08 +01:00
|
|
|
<span class="error-message" data-module="track-error" data-error-type="{{ field.errors[0] }}" data-error-label="{{ field.name }}">
|
2016-08-07 09:17:49 +01:00
|
|
|
{{ field.errors[0] }}
|
|
|
|
|
</span>
|
|
|
|
|
{% endif %}
|
|
|
|
|
</legend>
|
2016-10-11 14:17:29 +01:00
|
|
|
<div class="radio-select" data-module="radio-select" data-categories="{{ field.categories|join(',') }}">
|
2016-08-07 09:17:49 +01:00
|
|
|
<div class="radio-select-column">
|
|
|
|
|
{% for option in field %}
|
2016-12-19 10:36:17 +00:00
|
|
|
<div class="multiple-choice">
|
2016-08-07 09:17:49 +01:00
|
|
|
{{ option }}
|
2016-12-19 10:36:17 +00:00
|
|
|
<label for="{{ option.id }}">
|
|
|
|
|
{{ option.label.text }}
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
2016-08-07 09:17:49 +01:00
|
|
|
{% if loop.first %}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="radio-select-column">
|
|
|
|
|
{% endif %}
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</fieldset>
|
|
|
|
|
</div>
|
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
|
|
|
2018-06-12 14:29:47 +01:00
|
|
|
{% macro conditional_radio_panel(id) %}
|
2018-06-21 14:00:00 +01:00
|
|
|
<div class="conditional-radios-panel" id="panel-{{ id }}">
|
2018-06-12 14:29:47 +01:00
|
|
|
{{ caller() }}
|
|
|
|
|
</div>
|
|
|
|
|
{% endmacro %}
|