-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Introduced proxy methods to allow easier handling of form errors #29521
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
Conversation
* instances that where added to the top | ||
* level of this form | ||
*/ | ||
public function getOnlyGlobalErrors(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name sounds confusing for a form which is not the root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to stick with the naming in the current documentation:
// a FormErrorIterator instance, but only errors attached to this
// form level (e.g. global errors)
But getRootErrors()
works for me too if this is a naming we can agree on? The suggested getOwnErrors()
didn't appeal to me.
* instances that where added to the form | ||
* and the child forms | ||
*/ | ||
public function getAllErrors(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot change the interface until Symfony 5.0 for BC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually totally forgot about that part and agree. I've changed the description.
#SymfonyConHackDay2018 |
I have a different proposal for naming:
I think that when you see |
Another idea I like is @noahduncan 's proposal to add The word |
Buttons don't have child forms
I can see that this PR was started during SymfonyLive Hackaton. @zebba Are you still interested in working on it? |
Yes, I am up for it. |
Closing as this PR has been stale for a long time. Feel free to reopen whenever you find time to finish it. |
In order to create a better experience for new developers the introduction of two proxy methods seem to be a good idea when handling with forms. As stated in the issue it isn't always obvious as to why
$form->isValid()
will returnfalse
and$form->getErrors()
will leave you with nothing since you didn't think about the parameters to control the list of errors.Now, I've added two methods:
getAllErrors()
which is a shortcut for$form->getErrors(true)
andgetOnlyGlobalErrors()
an alias for the$form->getErrors()
call.#symfonyconhackday2018