$form_state->setErrorByName() breaks $form_state->set()

Created on 12 July 2023, about 1 year ago

I have a form that extends FormBase. In my implementation of ::validateForm(), when I use ::setErrorByName(), I want to pass data back to ::buildForm() so that I can display information to help the user fix the validation problem. I've tried using $form_state->set() in ::validateForm() but when I call $form_state->get() in ::buildForm(), the data is not there. (I tried calling $form_state->setRebuild(). It does not make a difference.)

The form is multi-step. If I do not call ::setErrorByName(), then the data set via $form_state->set() is available when the next page of the form is built in ::buildForm().

I think this is the same issue as in the parent ticket. (The form in the parent uses Ajax; mine does not. I don't think this issue is related to Ajax.) The parent was closed that this behaviour is expected. I don't understand why that would be.

πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
FormΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡¨πŸ‡¦Canada Liam Morland Ontario, CA πŸ‡¨πŸ‡¦

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024