From 54cfacb0467a802c37e809fd080cc2ee86b872c7 Mon Sep 17 00:00:00 2001 From: HeahDude Date: Fri, 16 Dec 2016 20:07:26 +0100 Subject: [PATCH] [Form] Fixed invalid state of non synchronized form --- src/Symfony/Component/Form/Form.php | 2 +- .../Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index d7109bd3ac3eb..7c94fe395f96f 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -758,7 +758,7 @@ public function isEmpty() */ public function isValid() { - if (!$this->submitted) { + if (!$this->submitted || $this->transformationFailure) { return false; } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index b675d5d6eee08..f7e8484fd840f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -524,6 +524,7 @@ public function testSubmitSingleNonExpandedInvalidChoice() $this->assertNull($form->getData()); $this->assertEquals('foobar', $form->getViewData()); + $this->assertFalse($form->isValid()); $this->assertFalse($form->isSynchronized()); } @@ -945,6 +946,7 @@ public function testSubmitSingleExpandedRequiredInvalidChoice() $this->assertNull($form->getData()); $this->assertSame('foobar', $form->getViewData()); $this->assertEmpty($form->getExtraData()); + $this->assertFalse($form->isValid()); $this->assertFalse($form->isSynchronized()); $this->assertFalse($form[0]->getData());