robsontenorio / mary

Laravel Blade UI Components for Livewire 3
https://mary-ui.com
Other
804 stars 88 forks source link

Select : allow Enums #490

Closed ryanvelbon closed 2 weeks ago

ryanvelbon commented 2 weeks ago

Currently <x-select> seems to only work with simple arrays.

If we tried passing in an Enum

@php
    $statusOptions = \App\Enums\PostStatus::cases();
@endphp

<x-select label="Status" :options="$statusOptions" wire:model="status" />

We would get the following error

Cannot use object of type App\Enums\PostStatus as array
robsontenorio commented 2 weeks ago

Could share that enum definition?

robsontenorio commented 2 weeks ago

Just modified to a simpler approach. Thanks!

ryanvelbon commented 2 weeks ago

This is a way cleaner approach! Thank you for merging.