Problem/Motivation
There is an edge case issue with the parent ticket, which aimed to fix the Previous button behavior on webforms that use WET-BOEW form validation. The parent ticket introduced JavaScript to prevent the Previous button from triggering client-side validation, allowing users to navigate back without completing required fields.
However, an issue occurs when the affected webform page contains a file upload (managed file) element.
In this scenario, clicking the Previous button results in the page simply refreshing and remaining on the same step, instead of navigating to the previous page. There are no JavaScript errors or Drupal log messages, making the issue difficult to diagnose.
Root Cause
The parent implementation uses form.submit() to bypass WET-BOEW validation. While this successfully avoids client-side validation, it introduces a side effect:
Native form.submit() does not include the clicked submit button’s name/value in the request.
Webform wizard navigation relies on the triggering button (e.g., op=Previous) to determine the correct step transition.
When a managed file element is present, the form rebuild process becomes more sensitive to the triggering element, and without the button value, the form rebuilds onto the same page instead of navigating backward.
Solution
Before calling form.submit(), explicitly inject a hidden input that preserves the clicked button’s name and value. This ensures Drupal/Webform correctly identifies the triggering action while still bypassing WET validation.
Example fix:
if (el.name) {
const hidden = document.createElement('input');
hidden.type = 'hidden';
hidden.name = el.name;
hidden.value = el.value;
form.appendChild(hidden);
}
form.submit();Result
- WET-BOEW validation is still bypassed for the Previous button
- The correct submit button context is preserved
- Webform wizard navigation works correctly, including on pages with file upload elements
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | wt-boew-form-validation-edge-case-fix-3580681-2.patch | 1.96 KB | smulvih2 |
Comments
Comment #2
smulvih2Patch attached fixes this edge case.
This issue occurs on my project based on WxT 5.6.x, but is most likely an issue with 6.3.x as well.
Comment #4
smulvih2Pushed to 6.3.x.