Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed
wants to merge 1 commit into from

Conversation

mikeSimonson
Copy link
Contributor

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

@@ -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)) {
Copy link
Contributor

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

Copy link
Contributor Author

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 ?

Copy link
Member

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

@stof
Copy link
Member

stof commented Jun 11, 2013

Please add a test for this method with a form containing a button, to avoid regressions

@mikeSimonson
Copy link
Contributor Author

I am a bit at loss as to know where(in what file) to put that test ?

@mikeSimonson
Copy link
Contributor Author

I wrote a test for it but it's a fatal error.
That means that I have no way of catching the error nicely if the test fail.
If the test fail, PHP crash everything.

Do I add the test like that ?

@stof
Copy link
Member

stof commented Jul 5, 2013

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)

@mikeSimonson
Copy link
Contributor Author

Done

@mikeSimonson
Copy link
Contributor Author

Hi,

Is there something else I need to do for the patch to be pulled ?

@mikeSimonson
Copy link
Contributor Author

Hi,

Any reason why this pull request is still pending ?
What did I do wrong and how can I fix-it, if possible ?

Thanks

@webmozart
Copy link
Contributor

@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

[Form] Fixed getErrorsAsString() when the form contains buttons

Otherwise this is good to merge. /cc @fabpot

@mikeSimonson
Copy link
Contributor Author

I can still squash my commits while I have already pushed them ?

What's the appropriate way to do that without braking everything ?

@webmozart
Copy link
Contributor

Squash them and then do

git push -f origin patch-1

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.
@mikeSimonson
Copy link
Contributor Author

I hope it's good now.

fabpot added a commit that referenced this pull request Sep 3, 2013
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
@fabpot fabpot closed this Sep 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Form][BUG]Button missing getErrorsAsString() method
5 participants