diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 34f96c4df6..9c4fe05195 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -662,7 +662,7 @@ class Form extends Field implements \IteratorAggregate, FormInterface */ public function getValidator() { - return $this->validator; + return $this->getOption('validator'); } /** diff --git a/tests/Symfony/Tests/Component/Form/FormTest.php b/tests/Symfony/Tests/Component/Form/FormTest.php index aff86d7eb0..558d968c56 100644 --- a/tests/Symfony/Tests/Component/Form/FormTest.php +++ b/tests/Symfony/Tests/Component/Form/FormTest.php @@ -169,6 +169,11 @@ class FormTest extends \PHPUnit_Framework_TestCase $this->assertFalse($form->isCsrfTokenValid()); } + public function testGetValidator() + { + $this->assertSame($this->validator, $this->form->getValidator()); + } + public function testValidationGroupNullByDefault() { $this->assertNull($this->form->getValidationGroups());