Skip to content

Commit fb8c69a

Browse files
committed
Merge branch '2.2' into 2.3
* 2.2: fixed CS Fixed the error handling when decoding invalid XML to avoid a Warning [Form] Fixed: The "data" option is taken into account even if it is NULL [DomCrawler] [HttpFoundation] Make `Content-Type` attributes identification case-insensitive Conflicts: src/Symfony/Component/Form/Extension/Core/Type/FormType.php
2 parents 4f67780 + 1354c44 commit fb8c69a

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Extension/Core/Type/FormType.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4141
{
4242
parent::buildForm($builder, $options);
4343

44+
$isDataOptionSet = array_key_exists('data', $options);
45+
4446
$builder
4547
->setRequired($options['required'])
4648
->setErrorBubbling($options['error_bubbling'])
@@ -50,8 +52,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5052
->setByReference($options['by_reference'])
5153
->setInheritData($options['inherit_data'])
5254
->setCompound($options['compound'])
53-
->setData(isset($options['data']) ? $options['data'] : null)
54-
->setDataLocked(isset($options['data']))
55+
->setData($isDataOptionSet ? $options['data'] : null)
56+
->setDataLocked($isDataOptionSet)
5557
->setDataMapper($options['compound'] ? new PropertyPathMapper($this->propertyAccessor) : null)
5658
->setMethod($options['method'])
5759
->setAction($options['action'])

Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,12 @@ public function testGetValuesForChoices()
257257
$this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices));
258258
}
259259

260-
261260
public function testGetValuesForChoicesPreservesKeys()
262261
{
263262
$choices = array(5 => $this->choice1, 8 => $this->choice2);
264263
$this->assertSame(array(5 => $this->value1, 8 => $this->value2), $this->list->getValuesForChoices($choices));
265264
}
266265

267-
268266
public function testGetValuesForChoicesPreservesOrder()
269267
{
270268
$choices = array($this->choice2, $this->choice1);

Tests/Extension/Core/Type/FormTypeTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,18 @@ public function testDataOptionSupersedesSetDataCalls()
546546
$this->assertSame('default', $form->getData());
547547
}
548548

549+
public function testDataOptionSupersedesSetDataCallsIfNull()
550+
{
551+
$form = $this->factory->create('form', null, array(
552+
'data' => null,
553+
'compound' => false,
554+
));
555+
556+
$form->setData('foobar');
557+
558+
$this->assertNull($form->getData());
559+
}
560+
549561
public function testNormDataIsPassedToView()
550562
{
551563
$view = $this->factory->createBuilder('form')

0 commit comments

Comments
 (0)