Account created on 5 March 2020, almost 5 years ago
#

Recent comments

🇧🇷Brazil daniel_arend

I can't understand why the test fails on d10. BTW, I'm using this patch in d10 version and PHP 8.2 and it works fine. It does not seem to be related to the patch itself, but some hash assertion with drupal libraries. Any help here would be much appreciated.

🇧🇷Brazil daniel_arend

Thanks 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.

🇧🇷Brazil daniel_arend

Here 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.

🇧🇷Brazil daniel_arend

Here follows the code I made. I also attached a video with the bug in action


 function mymodule_webform_submission_form_alter(&$form, $form_state, $form_id) {

    echo '<pre style="background:yellow;">';
    var_dump($form_state->getValues());
    echo '</pre>';
    
  }

🇧🇷Brazil daniel_arend

The value dump is part of the bug, because is the only way to detect that is running a double validation on the second step.

Production build 0.71.5 2024