Better support for displaying and resolving Casted Enum #4031
Replies: 3 comments 2 replies
-
|
Please provide full reproducing repository. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Same happens for Badge field. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
The problem is the expected value, and enums returns an object. use App\Enums\Status;
use Illuminate\Support\Collection;
Select::make('Status')
->options(
Collection::make(Status::cases())->mapWithKeys(fn ($status) => [$status->value => $status->value])
)->resolveUsing(fn($status) => $status->value
)->displayUsing(fn($status) => $status->value)The important points is |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
When casting a property to a PHP 8.1 enum (see https://laravel.com/docs/9.x/releases#enum-casting), a Nova Select field cannot be used. This leads to the following error:
This used to work in Laravel Nova 3.x.
Detailed steps to reproduce the issue on a fresh Nova installation:
Beta Was this translation helpful? Give feedback.
All reactions