feat(options): label above the control for every option, incl. checkboxes

On the custom options page (Simple options) the label now always renders
above the control. The checkbox exception (label right of the box via
form-check/form-check-label, incl. the 9 logo device checkboxes) is
removed; the generic form-label keeps the same id
(lbl_simple_edit_options_<key>) so JS/tests anchors are unchanged.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-25 19:21:35 +01:00
commit 858359ac71

View file

@ -351,13 +351,13 @@
{% set ckey = pos ~ 'showon' ~ dev %} {% set ckey = pos ~ 'showon' ~ dev %}
{% set cattr = aOptionAttributes.optionAttributes[ckey] %} {% set cattr = aOptionAttributes.optionAttributes[ckey] %}
{% set ccv = bGeneralInherit ? 'inherit' : (aCurrentOptions[ckey] is defined ? aCurrentOptions[ckey] : (oParentOptions[ckey] is defined ? oParentOptions[ckey] : '')) %} {% set ccv = bGeneralInherit ? 'inherit' : (aCurrentOptions[ckey] is defined ? aCurrentOptions[ckey] : (oParentOptions[ckey] is defined ? oParentOptions[ckey] : '')) %}
<div class="form-check mb-1"> <div class="mb-1">
<label for="simple_edit_options_{{ ckey }}" id="lbl_simple_edit_options_{{ ckey }}" class="form-label">{{ gT(cattr.title) }}</label>
<input type="checkbox" value="on" <input type="checkbox" value="on"
{% if ccv == 'on' %}checked{% endif %} {% if ccv == 'on' %}checked{% endif %}
class="form-check-input selector_option_checkbox_field" class="form-check-input selector_option_checkbox_field"
data-inheritvalue="{{ oParentOptions[ckey] }}" data-inheritvalue="{{ oParentOptions[ckey] }}"
id="simple_edit_options_{{ ckey }}" name="{{ ckey }}"> id="simple_edit_options_{{ ckey }}" name="{{ ckey }}">
<label for="simple_edit_options_{{ ckey }}" id="lbl_simple_edit_options_{{ ckey }}" class="form-check-label">{{ gT(cattr.title) }}</label>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
@ -405,12 +405,8 @@
<div class="{{ wrapClass }} {% if attr.parent != '' %}option-visibility{% if bParentHidden %} d-none{% endif %}{% endif %}" <div class="{{ wrapClass }} {% if attr.parent != '' %}option-visibility{% if bParentHidden %} d-none{% endif %}{% endif %}"
{% if attr.parent != '' %}data-show-if-parent="{{ attr.parent }}" data-show-if-value="{{ showIfValues }}"{% endif %}> {% if attr.parent != '' %}data-show-if-parent="{{ attr.parent }}" data-show-if-value="{{ showIfValues }}"{% endif %}>
<div class="mb-3"> <div class="mb-3">
{# label ALWAYS above the control, for every type EXCEPT checkbox {# label ALWAYS above the control, for every option type #}
(checkboxes carry their label to the RIGHT
of the box, rendered in the checkbox branch below) #}
{% if attr.type != 'checkbox' %}
<label for="simple_edit_options_{{ key }}" id="lbl_simple_edit_options_{{ key }}" class="form-label">{{ gT(attr.title) }}</label> <label for="simple_edit_options_{{ key }}" id="lbl_simple_edit_options_{{ key }}" class="form-label">{{ gT(attr.title) }}</label>
{% endif %}
{% if key == 'headersticky' %} {% if key == 'headersticky' %}
{% elseif attr.type == 'buttons' %} {% elseif attr.type == 'buttons' %}
@ -435,24 +431,18 @@
</div> </div>
{% elseif attr.type == 'checkbox' %} {% elseif attr.type == 'checkbox' %}
{# checkbox: checked = "on", unchecked = "off". EXCEPTION to the {# checkbox: checked = "on", unchecked = "off". The label sits above
label-above rule: for checkboxes the label stands to the box via the generic form-label at the top of this block (same
the RIGHT of the box (classic .form-check with the label after id lbl_simple_edit_options_<key>, so tests/JS anchors keep working).
the input) — so the generic form-label at the top of this block With survey-level inherit, an untouched box keeps the value
is skipped for checkboxes and the label is rendered here with "inherit" (options.js: data was-inherit). Children of a parent
the same id (lbl_simple_edit_options_<key>) so tests/JS anchors switch get selector_radio_childfield + data-parent. #}
keep working. With survey-level inherit, an untouched box keeps <input type="checkbox" value="on"
the value "inherit" (options.js: data was-inherit). Children of {% if currentValue == 'on' %}checked{% endif %}
a parent switch get selector_radio_childfield + data-parent. #} class="form-check-input selector_option_checkbox_field {% if attr.parent != '' %}selector_radio_childfield{% endif %}"
<div class="form-check"> {% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
<input type="checkbox" value="on" data-inheritvalue="{{ oParentOptions[key] }}"
{% if currentValue == 'on' %}checked{% endif %} id="simple_edit_options_{{ key }}" name="{{ key }}">
class="form-check-input selector_option_checkbox_field {% if attr.parent != '' %}selector_radio_childfield{% endif %}"
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
data-inheritvalue="{{ oParentOptions[key] }}"
id="simple_edit_options_{{ key }}" name="{{ key }}">
<label for="simple_edit_options_{{ key }}" id="lbl_simple_edit_options_{{ key }}" class="form-check-label">{{ gT(attr.title) }}</label>
</div>
{% elseif attr.type == 'dropdown' %} {% elseif attr.type == 'dropdown' %}
{% set ddClasses = 'form-select selector_option_value_field' %} {% set ddClasses = 'form-select selector_option_value_field' %}