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
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.
This commit is contained in:
parent
51014bf930
commit
6362fa41b0
|
@ -751,7 +751,7 @@ class Form implements \IteratorAggregate, FormInterface
|
|||
|
||||
foreach ($this->children as $key => $child) {
|
||||
$errors .= str_repeat(' ', $level).$key.":\n";
|
||||
if ($err = $child->getErrorsAsString($level + 4)) {
|
||||
if ($child instanceof self && $err = $child->getErrorsAsString($level + 4)) {
|
||||
$errors .= $err;
|
||||
} else {
|
||||
$errors .= str_repeat(' ', $level + 4)."No errors\n";
|
||||
|
|
|
@ -571,6 +571,20 @@ class FormTypeTest extends BaseTypeTest
|
|||
$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()
|
||||
{
|
||||
return 'form';
|
||||
|
|
Reference in New Issue