-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Support event listeners in buttons #8735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Long forgotten post I see. I do agree this should be added. Otherwise there's no way to remove buttons dynamically, ex: removing certain buttons based on user role. |
@wiejakp Would you try to work on implementing this feature? |
@fabpot, might attempt this if time allows. |
@wiejakp Current hack is to place SubmitType BEFORE an hidden element (or an element used in your form), addListener to the element and get parent getClickedButton() method.
|
@Romaxx , I'm not sure that's the case we're talking about. Well, OP was, but I'm having different issue with Event Listener. Buttons not being included in Form Event listeners means that buttons themselves aren't able to be removed from form model. Please note that this example clearly demonstrates behaviour that button is excluded from:
|
to @wiejakp, @webmozart dont talk about button removal, but listening button 'dynamic functionality can be built into forms that depends on whether a button was clicked or not', so my response is in that way. |
Ok, gotcha. I edited my post because it clicked in after few minutes. |
@fabpot , I'm wondering if you might have a word of advice on problem from this puzzle. I'm having an issue with button type's parent removing button form type from it's children collection, and I hope you have an idea why, or when should I call my event. Seems like buttons PR in question: https://github.com/wiejakp/form/pull/2 Extension for testing:
Form type for testing:
|
I fail to see a real use case for this feature. So I am going to close here. We can reconsider this decision in the future if more information pops up that indicates otherwise. |
The event POST_SUBMIT (and potentially PRE_SUBMIT, PRE_SET_DATA and POST_SET_DATA) should be supported on buttons. Using this event, dynamic functionality can be built into forms that depends on whether a button was clicked or not:
May be related to #5807.
The text was updated successfully, but these errors were encountered: