[Form] fixes empty file-inputs get treated as extra field
This commit is contained in:
parent
2e2a36ca24
commit
e5fba3cf83
@ -546,7 +546,7 @@ class Form implements \IteratorAggregate, FormInterface
|
|||||||
|
|
||||||
foreach ($this->children as $name => $child) {
|
foreach ($this->children as $name => $child) {
|
||||||
$fieldValue = null;
|
$fieldValue = null;
|
||||||
if (isset($submittedData[$name])) {
|
if (array_key_exists($name, $submittedData)) {
|
||||||
$fieldValue = $submittedData[$name];
|
$fieldValue = $submittedData[$name];
|
||||||
unset($submittedData[$name]);
|
unset($submittedData[$name]);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Tests;
|
|||||||
|
|
||||||
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
|
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
|
||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
|
use Symfony\Component\Form\Forms;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
|
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
|
||||||
@ -73,6 +74,19 @@ class CompoundFormTest extends AbstractFormTest
|
|||||||
$this->form->submit(array(), false);
|
$this->form->submit(array(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSubmitDoesNotAddExtraFieldForNullValues()
|
||||||
|
{
|
||||||
|
$factory = Forms::createFormFactoryBuilder()
|
||||||
|
->getFormFactory();
|
||||||
|
|
||||||
|
$child = $factory->create('file', null, array('auto_initialize' => false));
|
||||||
|
|
||||||
|
$this->form->add($child);
|
||||||
|
$this->form->submit(array('file' => null));
|
||||||
|
|
||||||
|
$this->assertCount(0, $this->form->getExtraData());
|
||||||
|
}
|
||||||
|
|
||||||
public function testClearMissingFlagIsForwarded()
|
public function testClearMissingFlagIsForwarded()
|
||||||
{
|
{
|
||||||
$child = $this->getMockForm('firstName');
|
$child = $this->getMockForm('firstName');
|
||||||
|
Reference in New Issue
Block a user