Problem/Motivation
After testing the new WET-BOEW inline form validation feature in parent ticket, there have been some field types identified with issues.
Problematic field types:
- Checkbox (single)
- Checkboxes (multiple)
- Radios
Current rendering for required fields:

Steps to reproduce
Install WxT 6.1.2, add a webform and enable the new "Enable WET-BOEW inline validation" option in the Settings tab. Add the problematic fields and look at webform.
Pull Requests (PR)
wxt_bootstrap: https://github.com/drupalwxt/wxt_bootstrap/pull/35
wxt: https://github.com/drupalwxt/wxt/pull/332
Comments
Comment #2
smulvih2Comment #3
smulvih2Here are the fields with the proper rendering.
You can pull these changes from this PR until merged - https://github.com/drupalwxt/wxt_bootstrap/pull/35
Comment #4
smulvih2Here is the fix for the checkbox/checkboxes/radios when the error is triggered:
Comment #5
smulvih2So far there is only one major issue with the WET-BOEW field validation integration with webforms, this is with the checkboxes field. WET-BOEW expects all checkboxes in a group to have the same
nameattribute on each<input>element, like this:You can see from this example, WET-BOEW expects all
inputelements to have the samename="animal". With webforms, thenameattribute is unique and used to save the value on form submit, so it can't easily be changed. Here is the same field in webforms (some attributes removed for brevity):You can see here that each
inputelement gets a uniquenameattribute, which can't be changed or will cause submission failure. Not sure the best way to approach this issue, maybe WET-BOEW has a workaround for this, but nothing I can find.Symptoms: When the checkboxes group is required, and you submit the form with the field blank, you get the error message as expected. Only selecting the first checkbox in the array will clear the message, although if you save the form it will then remove the message if another checkbox in the array is selected.
Comment #6
smulvih2Comment #7
smulvih2Comment #8
gdaw commentedAlong with the initial 3 fields mentioned above I noticed others as well, so I tested all the webform input fields to see which ones might still have bugs.
Some of these fields are popular, common or important enough to consider bringing them inline as well.
Here are my results showing if * is on the left with (Required) on the right, and/or if the validation message is displayed correctly on submit . Only fields that fail one or both are listed.
Comment #9
smulvih2Comment #10
smulvih2I added a PR for drupalwxt/wxt that handles conditional fields in webforms. The conditional fields work with the wet-boew validation, the only issue I noticed was they were not getting the proper required markers. This is because the required markers are added server-side via twig templates. I added a JavaScript file to a library that only gets loaded on webforms that have the wet-boew validation enabled. I tested this against normal fields with a
<label>element, as well as grouped fields with a<legend>.Pull requests:
drupal/wxt_bootstrap: https://github.com/drupalwxt/wxt_bootstrap/pull/35
drupalwxt/wxt: https://github.com/drupalwxt/wxt/pull/332
Comment #11
smulvih2Video attached showing the handling of conditionally-visible required fields. JS is needed since conditional fields uses JS on the front-end which bypasses the templates for the required markers.
Comment #12
joseph.olstadVery nice touch with the video, and ya bonus, conditional fields, this is how it was meant to be!
Comment #13
smulvih2Here are patches for Drupal 10 WxT with all of the WET-BOEW validation from the parent ticket, as well as the new fixes for grouped fields (checkbox, checkboxes, radios) and conditional fields.
Comment #14
smulvih2Finally fixed the checkbox group validation issue!
Initially, when enabling WET-BOEW inline validation in Drupal WxT, checkbox groups (#type: checkboxes) were not validating correctly.
Only the first checkbox in the group would remove the validation error once selected, while checking any other box would leave the error message active.
This caused real usability issues, if a user selected only the second or third option, the form still showed a “This field is required” error and could not be submitted.
Initial Analysis
In the default WET example, all checkboxes in a required group share the same name (e.g. name="animal"), which allows the jQuery Validate
require_from_grouprule to treat them as one logical field.However, in Drupal Webforms, each checkbox has a distinct name for submission purposes, such as:
Because of these unique names, the validator treated each input as a separate required field, so only the first checkbox’s change event satisfied the validation rule, the others continued to trigger “required” errors.
First Attempt
I added a shared CSS class and
data-rule-require_from_groupattributes in a preprocess hook to make WET recognize the grouped checkboxes.Example attributes added by preprocess:
This correctly enforced “at least one checked” behavior across all boxes, but introduced a new problem:
each checkbox still rendered its own inline validation message and corresponding entry in the WET summary, producing multiple duplicate errors for the same fieldset.
Final Fix
To resolve this, I implemented a client-side enhancement (
webform_checkboxes_group.js) that hooks into WET’s jQuery Validate instance once initialized.The script:
animal[dog]that includedata-rule-require_from_group.v.settings.groups.errorListanderrorMapto keep only one entry per checkbox base name.Result
Edit: Made a small improvement after pulling this into a project. When checkboxes in a group use accented characters OR spaces in the option keys, this causes an issue with the checkbox group fix.
I have updated the two PRs in this ticket with these changes:
wxt_bootstrap: https://github.com/drupalwxt/wxt_bootstrap/pull/35
wxt: https://github.com/drupalwxt/wxt/pull/332
Comment #15
smulvih2Drupal 10 PRs
These are the PRs to get this fix in Drupal 10. Please note, we need to update to wet-boew/wet-boew 4.0.85 in WxT 5.4.x in order to ensure wet-boew validation for checkbox group works as expected.
Edit: Made a small improvement after pulling this into a project. When checkboxes in a group use accented characters in the option key, this caused an issue with the checkbox group fix. This renders a
name="animal[écureuil]", which was causing the checkbox group fix to break.wxt_bootstrap: https://github.com/drupalwxt/wxt_bootstrap/pull/36
wxt: https://github.com/drupalwxt/wxt/pull/333
Comment #16
smulvih2Drupal 11 Patches
Adding patches to use in my project for D11, with the latest fix for checkbox groups using special characters and spaces in their options key.
Comment #17
smulvih2Included with 6.1.3.
In WxT 5.x the patches/PRs in #15 are still required since we are not adding this feature to 5.x.
Comment #19
smulvih2See this feature in action here (with conditional fields) - https://agriculture.canada.ca/en/form/accessibility-feedback-form