Skip to content

Commit 5b1f57e

Browse files
committed
improve item label
1 parent f27d7b6 commit 5b1f57e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Fields/FormSchemas/VisibilityRulesSchema.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
namespace Backstage\Fields\Fields\FormSchemas;
44

5-
use Backstage\Fields\Fields\Helpers\FieldOptionsHelper;
65
use Filament\Forms;
6+
use Backstage\Fields\Models\Field;
7+
use Backstage\Fields\Fields\Helpers\FieldOptionsHelper;
78

89
class VisibilityRulesSchema
910
{
@@ -71,7 +72,15 @@ public static function make(): array
7172
->visible(fn (Forms\Get $get): bool => !in_array($get('operator'), ['is_empty', 'is_not_empty'])),
7273
])
7374
->collapsible()
74-
->itemLabel(fn (array $state): ?string => $state['field'] ?? null)
75+
->itemLabel(function (array $state): ?string {
76+
77+
if (isset($state['field'])) {
78+
$field = Field::find($state['field']);
79+
return $field->name ?? null;
80+
}
81+
82+
return null;
83+
})
7584
->defaultItems(1)
7685
->columns(3)
7786
->reorderableWithButtons()
@@ -80,6 +89,7 @@ public static function make(): array
8089
->collapsible()
8190
->itemLabel(fn (array $state): ?string => 'Visibility Rule')
8291
->defaultItems(0)
92+
->maxItems(1)
8393
->reorderableWithButtons()
8494
->columnSpanFull(),
8595
]),

0 commit comments

Comments
 (0)