-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
[LiveComponent] [ComponentWithFormTrait] Force recreation of FormView on PreReRender hook to synchronize FormInstance and FormView. #2602
base: 2.x
Are you sure you want to change the base?
Conversation
…forcing a recreation of the FormView. Invoked only once with true in ComponentWithFormTrait::submitFormOnRender() to synchronize FormView and FormInstance
Recreating the FormView may lead to unwanted behavior regarding the Also, for performance reasons I would like to avoid adding a second validation. |
03a4ee6
to
319f885
Compare
…reation in case "shouldAutoSubmitForm" is true
It makes sense to me, WDYT @smnandre? |
I'm not 100% sure to be honest, looks to me this could have side effects, especially with recent changes. I will have a deeper look this week-end. Also tests here focus only on errors, and not on data. But the added comment states "Recreate the FormView because it has been created by the submitForm() with a FormInterface whose values may have changed". |
The data in this case would be the string |
Welcome aboard :)
Yes but this change will be executed for every component using this trait, on every re-render.. so there may be other cases :) |
Thank you! Finally able to pay some of it back \o/ The added change will force the recreation of the formView only in cases where the
If necessary due to performance implications we could always introduce a function Another thought: Is it even necessary to create the formView inside the |
Could theoretically potentially maybe also create a wrapper class for the FormInterface tracking all changes. However, I feel like that creates way too much overhead for what this PR is actually trying to solve...manual re-creation of the form is probably the option with the least impact on performance |
ComponentWithFormTrait will now recreate the existing FormView in its PreReRender-Hook
submitFormOnRender()
to synchronize FormView and FormInstance to reflect any manual changes to the FormInstance.This primarily solves the Problem of manually added FormErrors not being rendered.