Closed hdirki closed 9 months ago
Great plugin! Well done. I'm trying to add a radio deck for predefined enums. I think this plugin should support enums.
Here's an example Enum class:
<?php namespace App\Enums; use Filament\Support\Contracts\HasLabel; use Filament\Support\Contracts\HasIcon; enum ClientType: string implements HasLabel, HasIcon { case Individual = 'Individual'; case Organisation = 'Organisation'; public function getLabel(): ?string { $label = match ($this) { self::Individual => 'Individual', self::Organisation => 'Organisation', }; return $label; } public function getIcon(): ?string { return match ($this) { self::Individual => 'heroicon-m-user', self::Organisation => 'heroicon-m-building-office', }; } }
And the use case should be like this:
RadioDeck::make('client_type') ->options(ClientType::class)
And that would automatically load ->descriptions() and ->icons() unless there is a way already to do this?
->descriptions()
->icons()
1.1.1
8.2.1
10.39.0
macOS
No response
You can try to use enums for ->descriptions() and ->icons() . The docs is also update so you can see it how to implement. Thanks for this!
Release: v1.1.2
What happened?
Great plugin! Well done. I'm trying to add a radio deck for predefined enums. I think this plugin should support enums.
How to reproduce the bug
Here's an example Enum class:
And the use case should be like this:
And that would automatically load
->descriptions()
and->icons()
unless there is a way already to do this?Package Version
1.1.1
PHP Version
8.2.1
Laravel Version
10.39.0
Which operating systems does with happen with?
macOS
Notes
No response