Skip to content

Commit

Permalink
Fix bug in showing description of dynamic options
Browse files Browse the repository at this point in the history
  • Loading branch information
standaniels committed Oct 11, 2024
1 parent ef2cc4c commit ba3f6f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/forms/src/Components/Concerns/HasDescriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ public function getDescriptions(): array
$descriptions = $descriptions->toArray();
}

$options = $this->evaluate($this->options);

if (
empty($descriptions) &&
is_string($this->options) &&
enum_exists($this->options) &&
is_a($this->options, HasDescription::class, allow_string: true)
is_string($options) &&
enum_exists($options) &&
is_a($options, HasDescription::class, allow_string: true)
) {
$descriptions = array_reduce($this->options::cases(), function (array $carry, HasDescription & UnitEnum $case): array {
$descriptions = array_reduce($options::cases(), function (array $carry, HasDescription & UnitEnum $case): array {
if (filled($description = $case->getDescription())) {
$carry[$case?->value ?? $case->name] = $description;
}
Expand Down

0 comments on commit ba3f6f4

Please sign in to comment.