[Form] Introduced proxy methods to allow easier handling of form errors#29521
[Form] Introduced proxy methods to allow easier handling of form errors#29521zebba wants to merge 7 commits intosymfony:masterfrom
Conversation
| * instances that where added to the top | ||
| * level of this form | ||
| 8000 | */ | |
| public function getOnlyGlobalErrors(); |
There was a problem hiding this comment.
The name sounds confusing for a form which is not the root.
There was a problem hiding this comment.
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.
We cannot change the interface until Symfony 5.0 for BC.
There was a problem hiding this comment.
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 returnfalseand$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