Skip to content

Commit

Permalink
Set enum required if value is not empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored Feb 21, 2024
1 parent 4755371 commit 0892cee
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Controls/CheckboxListEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function setValue(/*?LabeledEnum*/ $values): self

$values = Arrays::map($values, function(mixed $value) {
if (isset($value) && !$value instanceof $this->enumType) {
$value = $this->enumType::make($value);
$value = $this->enumType::make($value, $value !== '');
}

return $value?->value;
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/RadioListEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function setItems(array $enums, bool $useKeys = true): self
public function setValue(/*?LabeledEnum*/ $value): self
{
if (isset($value) && !$value instanceof $this->enumType) {
$value = $this->enumType::make($value);
$value = $this->enumType::make($value, $value !== '');
}

return parent::setValue($value?->value ?? null);
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/SelectBoxEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function setItems(array $enums, bool $useKeys = true, bool $badge = false
public function setValue(/*?LabeledEnum*/ $value): self
{
if (isset($value) && !$value instanceof $this->enumType) {
$value = $this->enumType::make($value);
$value = $this->enumType::make($value, $value !== '');
}

return parent::setValue($value?->value ?? null);
Expand Down

0 comments on commit 0892cee

Please sign in to comment.