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