- Issue created by @bkline
- πΊπΈUnited States bkline Virginia
I have provided a repro case demonstrating the steps given above.
- Status changed to Postponed: needs info
over 1 year ago 4:48pm 2 September 2023 I think this may be more of a support request. Does https://drupal.stackexchange.com/questions/231436/form-ajax-not-working-... explain what you are seeing?
- πΊπΈUnited States bkline Virginia
I don't think so. I did, however, get some insight from Conrad Lara (@cmlara) in the Slack #support channel. Apparently Drupal sometimes (but not always) serializes the instance of the
FormBase
-derived class and then reconstitutes most of it, invokingsubmitForm()
on this partially-resurrected instance. In the process it drops theprivate
member variables on the floor. "Sometimes" likely means "when AJAX is in play" in this context. As far as Conrad is aware, this behavior isn't documented anywhere. But sure enough, when I replaceprivate
withprotected
in the repro code I posted the form works correctly. I will edit the original issue summary to clarify that it'sprivate
member variables which are discarded. - πΊπΈUnited States ddavisboxleitner
This has been an issue for us as well. Switching all private variables to protected works to preserve the data in those variables during AJAX calls.
There is documentation about the serialization issue: https://www.drupal.org/docs/drupal-apis/services-and-dependency-injectio... β