flowbite-bundle icon indicating copy to clipboard operation
flowbite-bundle copied to clipboard

Fix checkbox / switch fields invalid state

Open ldaspt opened this issue 6 months ago • 1 comments

In the custom form theme block checkbox_radio_label, the field validity is incorrectly determined using form.parent.vars.valid. This checks the validity of the entire parent form, not the individual field.

Fix #31

Current behavior

{% if checked and form.parent.vars.valid == false %}
    {% set valid = false %}
{% endif %}

Even if the current field has no validation error, it is marked as invalid if any other field in the parent form is invalid.

Expected behavior

The validity check should be scoped to the current field only.

🛠️ Impact

This causes incorrect error styling on checkbox or radio labels, even when they are valid, as soon as any unrelated form field fails validation.

ldaspt avatar Jun 03 '25 14:06 ldaspt

just as a follow up, I have overridden the checkbox_radio_label and switch_label blocks with your fix on one of my project and this seems to fix the issue well !

thanks a lot

j0r1s avatar Oct 27 '25 10:10 j0r1s