diff --git a/src/Element/AbstractElement.php b/src/Element/AbstractElement.php index bda4391..f062e38 100644 --- a/src/Element/AbstractElement.php +++ b/src/Element/AbstractElement.php @@ -350,9 +350,13 @@ public function setTransformer(TransformerInterface $transformer): void */ public function isSubmitted(): bool { - $form = $this->getForm(); + $submittedForm = $this->getForm()?->isSubmitted(); - return $form?->isSubmitted() ?? $this->submitted; + if (true === $submittedForm) { + return $this->submitted; + } + + return $submittedForm ?? $this->submitted; } /** diff --git a/tests/HydratorTest.php b/tests/HydratorTest.php index 83b4675..421eb74 100644 --- a/tests/HydratorTest.php +++ b/tests/HydratorTest.php @@ -198,7 +198,7 @@ public function testHydrateCollectionWithGroupEmpty() $person ->setAddresses( [ - (new FakeAddress()) + $expectedAddress = (new FakeAddress()) ->setAddress('2 avenue Paris') ->setAddressNext('BP 12345') ->setZipCode('75001') @@ -234,7 +234,7 @@ public function testHydrateCollectionWithGroupEmpty() $hydrator = new FormHydrator($form); $hydrator->hydrate($person); - $this->assertEquals([], $person->getAddresses()); + $this->assertEquals([$expectedAddress], $person->getAddresses()); } public function testPartialMapped() diff --git a/tests/Type/AbstractTypeTest.php b/tests/Type/AbstractTypeTest.php index 0a2dafb..e2490ce 100644 --- a/tests/Type/AbstractTypeTest.php +++ b/tests/Type/AbstractTypeTest.php @@ -158,7 +158,7 @@ public function testValue() $type->setValue('test'); $this->assertSame('test', $type->getValue()); -// + $type->submitValue('bar'); $this->assertSame('bar', $type->getValue());