Skip to content

Commit 5a8c826

Browse files
authored
fix: grouping fields (#40)
* fix: grouping fields * fix: remove unnecessary `live()` * fix: update deprecated form to schema
1 parent 1d2ce50 commit 5a8c826

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Fields/Repeater.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function getForm(): array
138138
->disabled(fn (string $operation) => $operation === 'create')
139139
->hint(fn (string $operation) => $operation === 'create' ? __('Fields can be added once the field is created.') : '')
140140
->hintColor('primary')
141-
->form([
141+
->schema([
142142
Section::make('Field')
143143
->columns(3)
144144
->schema([

src/Filament/RelationManagers/FieldsRelationManager.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,19 @@ public function form(Schema $schema): Schema
105105
})
106106
->searchable()
107107
->preload()
108-
->options(function () {
109-
return Field::pluck('group')
108+
->options(function (Get $get) {
109+
$existingGroups = Field::pluck('group')
110110
->filter()
111111
->unique()
112112
->mapWithKeys(fn ($group) => [$group => $group])
113113
->toArray();
114+
115+
$currentValue = $get('group');
116+
if ($currentValue && ! array_key_exists($currentValue, $existingGroups)) {
117+
$existingGroups[$currentValue] = $currentValue;
118+
}
119+
120+
return $existingGroups;
114121
}),
115122

116123
]),

0 commit comments

Comments
 (0)