It is a multipage Ajax form and I need to alter elements in a page based on form validation . This means, even if validation fails and the form stays on the same page, I need to visually alter that form page. Setting a field error with $form_state->setErrorByName
is not sufficient for me so I'm exploring other options that I can't seem to find :)
I've tried using $form_state->set()
and $form_state->setTemporary()
but it seems the values set this way are only set if the validations passes. If validation fails, I get NULLs back in buildForm.
I've also tried storing to Drupal session, which works, but not as expected since my form is an Ajax form and the session variable would only be available on a second submit and would persist one step further than needed.
And I'm out of options.
Any suggestions?
PS I'm on Drupal 10.