merged branch mikeSimonson/patch-1 (PR #8247)
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
This commit is contained in:
commit
a14ba2b65d
@ -751,7 +751,7 @@ class Form implements \IteratorAggregate, FormInterface
|
|||||||
|
|
||||||
foreach ($this->children as $key => $child) {
|
foreach ($this->children as $key => $child) {
|
||||||
$errors .= str_repeat(' ', $level).$key.":\n";
|
$errors .= str_repeat(' ', $level).$key.":\n";
|
||||||
if ($err = $child->getErrorsAsString($level + 4)) {
|
if ($child instanceof self && $err = $child->getErrorsAsString($level + 4)) {
|
||||||
$errors .= $err;
|
$errors .= $err;
|
||||||
} else {
|
} else {
|
||||||
$errors .= str_repeat(' ', $level + 4)."No errors\n";
|
$errors .= str_repeat(' ', $level + 4)."No errors\n";
|
||||||
|
@ -571,6 +571,20 @@ class FormTypeTest extends BaseTypeTest
|
|||||||
$this->assertSame('0', $view->vars['label']);
|
$this->assertSame('0', $view->vars['label']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCanGetErrorsWhenButtonInForm()
|
||||||
|
{
|
||||||
|
$builder = $this->factory->createBuilder('form', null, array(
|
||||||
|
'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author',
|
||||||
|
'required' => false,
|
||||||
|
));
|
||||||
|
$builder->add('foo', 'text');
|
||||||
|
$builder->add('submit', 'submit');
|
||||||
|
$form = $builder->getForm();
|
||||||
|
|
||||||
|
//This method should not throw a Fatal Error Exception.
|
||||||
|
$form->getErrorsAsString();
|
||||||
|
}
|
||||||
|
|
||||||
protected function getTestedType()
|
protected function getTestedType()
|
||||||
{
|
{
|
||||||
return 'form';
|
return 'form';
|
||||||
|
Reference in New Issue
Block a user