Skip to content

Commit

Permalink
Fix isSubmitted() of AbstractElement
Browse files Browse the repository at this point in the history
  • Loading branch information
ElGigi committed Nov 22, 2024
1 parent 1aabc3e commit b6aaffc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/Element/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/HydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function testHydrateCollectionWithGroupEmpty()
$person
->setAddresses(
[
(new FakeAddress())
$expectedAddress = (new FakeAddress())
->setAddress('2 avenue Paris')
->setAddressNext('BP 12345')
->setZipCode('75001')
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/Type/AbstractTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testValue()

$type->setValue('test');
$this->assertSame('test', $type->getValue());
//

$type->submitValue('bar');
$this->assertSame('bar', $type->getValue());

Expand Down

0 comments on commit b6aaffc

Please sign in to comment.