LiveListener event is also triggering component form submit #3306
Replies: 3 comments 2 replies
-
|
Can you clarify what components you have here (you talk "this" component vs component 1 / component 2), and also what you display the first time you renderer the component / if you have something else in its template. As i don't see in logs when "remove" is called and when is "save" |
Beta Was this translation helpful? Give feedback.
-
Here reproducer, sorry for the extra folder level: https://github.com/FluffyDiscord/symfony-ux-repro/tree/master/repro |
Beta Was this translation helpful? Give feedback.
-
|
Ok, so yes, this is one of those hard-to-read edge cases. You should dig directly into TL;DR: your component form was valid, but once you remove that code it's not anymore. Component forms are re-submitted for validation on the default render (when validation has already started). Since code is now null, you end up with a Let me know if reading the code makes things clearer, or if you have any other questions. One more thing: is this the real code, or a very simplified version? To be honest, I m not sure I understand why you have two components here, and could suggest a simplification. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have live component with form
Now when I trigger the
removeaction by clicking my button in this componentI can see that it correctly triggers the
GlobalTwigEvent::ORDER_CHANGEDevent, sending it as a POST also to this component (that's fine, it has a listener for it after all), but instead of only running the listener logic, it also handles the form for some reason, getting back status code 422 because of course it's invalid, no form/fields have been submitted. This happens only when the form has been sent at least once.I would expect it to just run the listener itself, no form submission should take place
Beta Was this translation helpful? Give feedback.
All reactions