Skip to content

Commit

Permalink
Form // cleanup variables and docBlocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrico committed Jun 27, 2023
1 parent 3a7bfe7 commit 16e6b2c
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/Element/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class Form extends CollectionElement implements FormInterface

protected bool $isValid = true;

protected bool $validated = false;

protected bool $isSubmitted = false;

/**
Expand Down Expand Up @@ -65,7 +63,6 @@ public function withData(array $data = []): FormInterface
throw new LogicException('You cannot change data of a submitted form.');
}

/** @var ElementInterface $element */
foreach ($this->elements() as $name => $element) {
$value = $data[$name] ?? '';
$this->rawData[$name] = $value;
Expand All @@ -84,11 +81,9 @@ public function withData(array $data = []): FormInterface
*/
public function submit(array $inputData = [])
{
$this->validated = false;
$this->isSubmitted = true;
$this->isValid = true;

/** @var ElementInterface $element */
foreach ($this->elements() as $name => $element) {
// only validate elements which are not disabled.
if ($element->isDisabled()) {
Expand Down Expand Up @@ -124,7 +119,7 @@ public function isValid(): bool
{
if (!$this->isSubmitted) {
throw new LogicException(
'Cannot check if a not submitted form is valid. Call Form::is_submitted() before Form::is_valid().'
'You need to call Form::submit() first, before checking Form::isValid().'
);
}

Expand Down

0 comments on commit 16e6b2c

Please sign in to comment.