-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form][BUG]Button missing getErrorsAsString() fixes #8084 #8247
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
@@ -747,7 +747,7 @@ public function getErrorsAsString($level = 0) | |||
|
|||
foreach ($this->children as $key => $child) { | |||
$errors .= str_repeat(' ', $level).$key.":\n"; | |||
if ($err = $child->getErrorsAsString($level + 4)) { | |||
if (method_exists($child, 'getErrorsAsString') && $err = $child->getErrorsAsString($level + 4)) { |
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.
this should probably be fixed with some kind of interface. Doing a method_exists check is rather ugly IMO
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 agree.
But having a getErrorAsString method in a Submit button class wouldn't mean much neither.
I don't think that having a method that always return false would be a better option.
Do you think that it should go into the FormInterface ?
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.
Well, you can already do it with a instanceof check: if ($child instanceof self) {
. It will exclude buttons which are using a different implementation
Please add a test for this method with a form containing a button, to avoid regressions |
I am a bit at loss as to know where(in what file) to put that test ? |
I wrote a test for it but it's a fatal error. Do I add the test like that ? |
Yes. I will still ensure that there is no regression (a fatal error crashing the testsuite is a failure for the testsuite, not a successful build) |
Done |
Hi, Is there something else I need to do for the patch to be pulled ? |
Hi, Any reason why this pull request is still pending ? Thanks |
@mikeSimonson Sorry for the slow response. Could you please squash your commits into one? Please also rename the commit message to something more explicit, such as
Otherwise this is good to merge. /cc @fabpot |
I can still squash my commits while I have already pushed them ? What's the appropriate way to do that without braking everything ? |
Squash them and then do
|
Debug: Not calling undefined method anymore. If the form contained a submit button the call would fail and the debug of the form wasn't possible. Now it will work in all cases. This fixes symfony#8084 Adding a test for the fix of getErrorAsString on Form. Was throwing a fatal because of a method that did not exist on the new element type button.
I hope it's good now. |
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #8247). Discussion ---------- [Form][BUG]Button missing getErrorsAsString() fixes #8084 Debug: Not calling undefined method anymore. If the form contained a submit button the call would fail and the debug of the form wasn't possible. Now it will work in all cases. This fixes #8084 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8084 | License | MIT Commits ------- dab0688 [Form][BUG]Button missing getErrorsAsString() fixes #8084 Debug: Not calling undefined method anymore. If the form contained a submit button the call would fail and the debug of the form wasn't possible. Now it will work in all cases. This fixes #8084
Debug: Not calling undefined method anymore.
If the form contained a submit button the call would fail and the debug of the form wasn't possible.
Now it will work in all cases.
This fixes #8084