Skip to content

Commit

Permalink
Merge pull request #8 from kgrzelak/dev
Browse files Browse the repository at this point in the history
instance of BackedEnum
  • Loading branch information
kgrzelak authored Jun 20, 2024
2 parents 33af928 + 647629a commit 8109b5d
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 8109b5d

Please sign in to comment.