diff --git a/src/Items/BaseItem.php b/src/Items/BaseItem.php index db1361c..ec11665 100644 --- a/src/Items/BaseItem.php +++ b/src/Items/BaseItem.php @@ -2,6 +2,7 @@ namespace Kgrzelak\LaravelForm\Items; +use BackedEnum; use Illuminate\Contracts\Support\Htmlable; use Stringable; @@ -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; @@ -96,9 +101,9 @@ public function toHtml(): string 'options' => $this->options ])->render(); } - + public function __toString(): string { return $this->toHtml(); } -} \ No newline at end of file +}