Skip to content

Commit

Permalink
MultiSelectElement: Move isValid() code to method validate()
Browse files Browse the repository at this point in the history
Parent method `isValid()` calls the `validate()` method
  • Loading branch information
sukhwinder33445 committed Jul 15, 2022
1 parent 5ffe5ef commit 7dd0883
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/FormElement/MultiSelectElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,14 @@ public function setValue($value)
return $this;
}

public function isValid()
public function validate()
{
if ($this->valid === null) {
if ($this->isRequired() && empty($this->getValue())) {
return false;
}
if ($this->isRequired() && empty($this->getValue())) {
$this->valid = false;

$this->validate();
return $this;
}

return $this->valid;
}

public function validate()
{
foreach ($this->getValue() as $value) {
$option = $this->getOption($value);
if (! $option || $option->getAttributes()->has('disabled')) {
Expand Down

0 comments on commit 7dd0883

Please sign in to comment.