Using webform conditions to set a checkbox element to not required does not work as intended. The user interface is updated accordingly, but the required attribute is still present, hence making it impossible to submit the form.

The bug is only present in case of a checkbox, but *not* for a radio buttons. It also works as intended if the element is hidden instead.

Comments

sammuell created an issue. See original summary.

sammuell’s picture

Version: 8.x-4.x-dev » 7.x-4.x-dev
StatusFileSize
new19.49 KB
new16.76 KB
new10.68 KB
sammuell’s picture

StatusFileSize
new790 bytes

When updating the required state in webform.js checkboxes are generally excluded in the respective selector (see attached patch file). If checkboxes are included in the selector it works as intended. However, I don't know if checkboxes have simply been forgotten or excluded on purpose.

liam morland’s picture

Status: Active » Needs review
liam morland’s picture

sammuell’s picture

I'm wondering why the current implementation specifically lists some input types. Looking at the referenced issue I think it would make sense to simplify.
var $targetInputElements = $target.find("input,textarea,select");

liam morland’s picture

Title: Reqired condition does not work for checkboxes » Conditional required does not work for single checkbox

The problem only appears in cases were there is just one checkbox. Otherwise, @required is not set anyway.

  • Liam Morland committed 61ec37f on 7.x-4.x authored by sammuell
    Issue #3032336 by sammuell: Allow conditionals to remove @required from...
liam morland’s picture

Status: Needs review » Fixed

Thanks for the patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jitendrapurohit’s picture

StatusFileSize
new6.7 KB

This breaks the form when you have a conditional of making the checkbox group required on a radio click.

With this patch applied, the form isn't submitted unless we check ALL the checkboxes present in the group. I've attached a simple webform to replicate this usecase.

- Select radion button "Yes" to make the checkbox attribute required.
- Enable one of the checkbox and submit the form. It displays a validation error to enable all the checkboxes.

liam morland’s picture

@#11: I think what you are reporting is already reported in #3100921: Multiple value select options requiring all boxes be checked.