Skip to content

Commit

Permalink
instance of BackedEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
kgrzelak committed Jun 20, 2024
1 parent a274e55 commit 647629a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Items/BaseItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Kgrzelak\LaravelForm\Items;

use BackedEnum;
use Illuminate\Contracts\Support\Htmlable;
use Stringable;

Expand Down Expand Up @@ -48,8 +49,12 @@ public function setType(string $type): static
return $this;
}

public function setValue(?string $value = null): static
public function setValue(mixed $value = null): static
{
if ($value instanceof BackedEnum) {
$value = $value->value;
}

$this->value = $value;

return $this;
Expand Down Expand Up @@ -96,9 +101,9 @@ public function toHtml(): string
'options' => $this->options
])->render();
}

public function __toString(): string
{
return $this->toHtml();
}
}
}

0 comments on commit 647629a

Please sign in to comment.