8000 Bug #13291 [Form] Forward Form::submit(Request) to Form::HandleRequest · 0mars/symfony@ef46e56 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef46e56

Browse files
committed
Bug symfony#13291 [Form] Forward Form::submit(Request) to Form::HandleRequest
Fixes the issue with uploaded files exceeding post_max_size, and form marked valid with empty fields
1 parent 8879a5f commit ef46e56

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Symfony/Component/Form/Form.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Form\Util\InheritDataAwareIterator;
2222
use Symfony\Component\Form\Util\OrderedHashMap;
2323
use Symfony\Component\PropertyAccess\PropertyPath;
24+
use Symfony\Component\HttpFoundation\Request;
2425

2526
/**
2627
* Form represents a form.
@@ -507,6 +508,11 @@ public function handleRequest($request = null)
507508
*/
508509
public function submit($submittedData, $clearMissing = true)
509510
{
511+
if ($submittedData instanceof Request) {
512+
@trigger_error('Passing a Symfony\Component\HttpFoundation\Request object to the '.__CLASS__.'::bind and '.__METHOD__.' methods is deprecated since 2.3 and will be removed in 3.0. Use the '.__CLASS__.'::handleRequest method instead. If you want to test whether the form was submitted separately, you can use the '.__CLASS__.'::isSubmitted method.', E_USER_DEPRECATED);
513+
return $this->handleRequest($submittedData);
514+
}
515+
510516
if ($this->submitted) {
511517
throw new AlreadySubmittedException('A form can only be submitted once');
512518
}

src/Symfony/Component/Form/Tests/SimpleFormTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,25 @@ public function testHandleRequestForwardsToRequestHandler()
909909
$this->assertSame($form, $form->handleRequest('REQUEST'));
910910
}
911911

912+
/**
913+
* Shall be removed in 3.0
914+
*/
915+
public function testSubmitForwardsToRequestHandlerUsingRequestArgument()
916+
{
917+
$handler = $this->getMock('Symfony\Component\Form\RequestHandlerInterface');
918+
919+
$form = $this->getBuilder()
920+
->setRequestHandler($handler)
921+
->getForm();
922+
923+
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
924+
925+
$handler->expects($this->once())
926+
->method('handleRequest')
927+
->with($this->identicalTo($form), $request);
928+
$this->assertSame($form, $form->submit($request));
929+
}
930+
912931
public function testFormInheritsParentData()
913932
{
914933
$child = $this->getBuilder('child')

0 commit comments

Comments
 (0)
0