diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 7a18dcb80078a..2cad0cf2ad1b2 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -21,6 +21,7 @@ use Symfony\Component\Form\Util\InheritDataAwareIterator; use Symfony\Component\Form\Util\OrderedHashMap; use Symfony\Component\PropertyAccess\PropertyPath; +use Symfony\Component\HttpFoundation\Request; /** * Form represents a form. @@ -511,6 +512,10 @@ public function submit($submittedData, $clearMissing = true) throw new AlreadySubmittedException('A form can only be submitted once'); } + if ($submittedData instanceof Request) { + return $this->handleRequest($submittedData); + } + // Initialize errors in the very beginning so that we don't lose any // errors added during listeners $this->errors = array(); diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index 76752b9bd235a..bea0a67426437 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -909,6 +909,44 @@ public function testHandleRequestForwardsToRequestHandler() $this->assertSame($form, $form->handleRequest('REQUEST')); } + /** + * Shall be removed in 3.0. + */ + public function testSubmitForwardsToRequestHandlerUsingRequestArgument() + { + $handler = $this->getMock('Symfony\Component\Form\RequestHandlerInterface'); + + $form = $this->getBuilder() + ->setRequestHandler($handler) + ->getForm(); + + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + + $handler->expects($this->once()) + ->method('handleRequest') + ->with($this->identicalTo($form), $request); + $this->assertSame($form, $form->submit($request)); + } + + /** + * Shall be removed in 3.0. + */ + public function testBindForwardsToRequestHandler() + { + $handler = $this->getMock('Symfony\Component\Form\RequestHandlerInterface'); + + $form = $this->getBuilder() + ->setRequestHandler($handler) + ->getForm(); + + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + + $handler->expects($this->once()) + ->method('handleRequest') + ->with($this->identicalTo($form), $request); + $this->assertSame($form, $form->bind($request)); + } + public function testFormInheritsParentData() { $child = $this->getBuilder('child')
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: