[Live Component] How to submit form with submit button only? #2911
Unanswered
matthieumastadenis
asked this question in
Questions & Answers
Replies: 2 comments
-
Hi @matthieumastadenis ! I agree with all your message, except the "probably not possible" part.. Disable auto-validation/submit
See: https://symfony.com/bundles/ux-live-component/current/index.html#deferring-a-re-render-until-later Submit with a buttonJust a bit after in the same doc section
Enjoy ;) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks @smnandre, it works perfectly! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Everything is in the title: How can I force a live component with form (using
ComponentWithFormTrait
) to only submit the form after a click on the submit button, and NOT automatically?I feel like this is something very simple, yet I can't figure how to achieve it. I asked around already, some people actually said to me that it was probably not possible because the point of live components with forms IS to auto submit.
Yet I disagree with that statement. There are many situations where autosubmit is not the best scenario, like for example:
One could say "don't use live components then", but I also disagree with that. Even if sometimes I don't want autosubmit, I may still want to benefit from:
I already searched for similar issues and the closest I found was 1858. But it is very specific to the "multiple buttons" scenario, so that's not the solution to what I'm asking.
I tried a lot of different combinations with the attributes
data-action
anddata-model
, but nothing seems to work. At best the form is still submitted automatically when I change a field, at worst the form is submitted without calling my live component.I feel like I've tried everything so now I allow myself to ask. Is this even possible? If so, how exactly please? 🙏
Beta Was this translation helpful? Give feedback.
All reactions