Closed (cannot reproduce)
Project:
Webform
Version:
6.3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jun 2023 at 20:23 UTC
Updated:
14 May 2026 at 21:51 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
cilefen commentedPlease provide the YAML of a minimal example form.
Comment #3
cilefen commentedAlso, can you explain steps to reproduce that describe the bug behavior, without the value dumping?
Comment #4
daniel_arend commentedYaml file is uploaded.
Comment #5
daniel_arend commentedComment #6
daniel_arend commentedThe value dump is part of the bug, because is the only way to detect that is running a double validation on the second step.
Comment #7
daniel_arend commentedHere follows the code I made. I also attached a video with the bug in action
Comment #8
daniel_arend commentedComment #9
daniel_arend commentedComment #10
henriquesf commentedSame issue!
Comment #11
daniel_arend commentedHere is some explanation about what I tried to fix the issue:
https://excalidraw.com/#json=R75jneYKHbK13FMsuLg7H,uxFDrzKLtZadt8ZxBFm6Cg
Somehow, the step #2 do additional things (rebuild maybe) that trigger the form_alter hook twice. At first trigger, the form_state variable is empty, the 2nd one the form_state values are set as should be.
It seems to be something on the way between stack 1 and stack 4 (link above).
I also tracked the overrideSettings method line by line, but could not find where/why is this hook triggering twice only in the 2nd step.
I hope this info helps to find the root cause.
Comment #12
jrockowitz commentedI am confused because this does not seem to be a regression.
When multistep forms render the form is built (no values), processed (callback), and rebuilt (with values).
Comment #13
henriquesf commentedI am with the same issue.
Comment #14
daniel_arend commentedThanks for the feedback. The workflow you described makes sense. But I'm still stucked into something I can only solve using form_alter hook.
The complete scenario is:
I have a multi-step form and need to do some extra validations after the user clicks on "prev/next" button. So I'm checking form state values inside this form_alter hook.
As it triggers twice (and it happens only on the 2nd step), the first time this info is empty (build), and only after rebuild, the values are set.
This will throw a false validation error (2nd step) on build, and then will pass on the second one, when values are set.
It gets more strange, because all other steps (1, 3, 4, etc) it runs only once and works exactly like it should.
As we need to check step by step, a custom handler would not solve the issue.
Comment #15
henriquesf commentedUp!
Comment #16
jrockowitz commentedSomeone who is experiencing this issue is going to have to debug it.
Comment #17
gpapadas commentedI am experiencing an issue that is quite the same. In one particular webform, while I am on the 2nd step I click Next to go the 3rd, I am redirected to the 1st step, and I get an error saying that the required fields of the first step are empty. This happens randomly. The behavior is the same as I was on the 2nd step and clicked the refresh button from the browser and then Resend.
@daniel_arend did you manage to solve this?
Comment #18
dhanalakshmi1013 commentedI'm having the same issue, but in a different way with Ajax enable in webform. I have a multistep webform with 9 steps and each step data sending to Datalayer GTM. Only 5,6,7 steps are submitting twice in GTM console rest all are sending the event once. While debugging this issue, I have observed that Alter_form where my datalayer JS is attached is calling twice on a single submit.
Also the same behaviour is not happening on Disabling Ajax in the form settings.
Can anyone share thoughts on this please!
Comment #19
jrockowitz commentedComment #20
jrockowitz commentedComment #21
liam morlandIs anyone able to reproduce this on current versions of Webform and Drupal?
Comment #22
liam morland