Skip to content

Commit

Permalink
Enum add Hidden attr and hide them in ListField #1096
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Sep 17, 2024
1 parent 1bf8d2f commit 294c1a8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Field/Concern/ListOptionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Windwalker\DOM\HTMLFactory;
use Windwalker\Utilities\Assert\TypeAssert;
use Windwalker\Utilities\Contract\LanguageInterface;
use Windwalker\Utilities\Enum\EnumMetaInterface;
use Windwalker\Utilities\Enum\EnumTranslatableInterface;

/**
Expand Down Expand Up @@ -135,6 +136,10 @@ public function registerFromEnums(iterable|string $enums, ?LanguageInterface $la
$options = [];

foreach ($enums as $enum) {
if (($enum instanceof EnumMetaInterface) && $enum->isHidden()) {
continue;
}

if ($enum instanceof EnumTranslatableInterface) {
$options[$enum->getValue()] = $enum->getTitle($lang) ?: $enum->getKey();
} elseif ($enum instanceof Enum) {
Expand Down

0 comments on commit 294c1a8

Please sign in to comment.