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:
mike 2013-06-11 23:05:51 +02:00 committed by Fabien Potencier
parent 51014bf930
commit 6362fa41b0
2 changed files with 15 additions and 1 deletions

View File

@ -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";

View File

@ -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';