[Form] Added getValidators() to Form class

This commit is contained in:
mlively 2011-12-28 12:47:11 -08:00
parent cab70f4083
commit 601d462589
2 changed files with 20 additions and 0 deletions

View File

@ -770,6 +770,16 @@ class Form implements \IteratorAggregate, FormInterface
return $this->clientTransformers;
}
/**
* Returns the Validators
*
* @return array An array of FormValidatorInterface
*/
public function getValidators()
{
return $this->validators;
}
/**
* Returns all children in this group.
*

View File

@ -1024,6 +1024,16 @@ class FormTest extends \PHPUnit_Framework_TestCase
$this->assertEquals("name:\n ERROR: Error!\nfoo:\n No errors\n", $parent->getErrorsAsString());
}
public function testGetValidatorsReturnsValidators()
{
$validator = $this->getFormValidator();
$form = $this->getBuilder()
->addValidator($validator)
->getForm();
$this->assertEquals(array($validator), $form->getValidators());
}
protected function getBuilder($name = 'name', EventDispatcherInterface $dispatcher = null)
{
return new FormBuilder($name, $this->factory, $dispatcher ?: $this->dispatcher);