You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #2553 [LiveComponent] Fix ComponentWithFormTrait not working in batch actions (smnandre)
This PR was merged into the 2.x branch.
Discussion
----------
[LiveComponent] Fix ComponentWithFormTrait not working in batch actions
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| Issues | Fix#1509
| License | MIT
Fix#1509
Thank you `@jpvdw86` for your work on this! 👏
Some parts of your PR would have introduced changes affecting all LiveComponent instances, including those not using ComponentWithFormTrait. To keep the impact as minimal as possible, I’ve opted for a more targeted fix.
But _you_ did all the hard work here—much appreciated! 🚀
Commits
-------
466c4eb [LiveComponent] Fix ComponentWithFormTrait not working in batch actions
thrownew \LogicException('The submitForm() method is being called, but the FormView has already been built. Are you calling $this->getForm() - which creates the FormView - before submitting the form?');
152
+
// Two scenarios can cause this:
153
+
// 1) Not intended: form was already submitted and validated in the same main request.
154
+
// 2) Expected: form was submitted during a sub-request (e.g., a batch action).
155
+
//
156
+
// Before 2.23, both cases triggered an exception.
157
+
// Since 2.23, we reset the form (preserving its values) to handle case 2 correctly.
0 commit comments