Skip to content

Commit 4f043c0

Browse files
committed
Fix category switcher state and update form default
Added dehydrateStateUsing to DocumentTypeCategorySwitcher to prevent dirty state issues with the model. Removed unnecessary 'live' method from the 'show_as_table' field in DocumentTypeForm.
1 parent 352b555 commit 4f043c0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Filament/Resources/DocumentTypes/Schemas/Components/DocumentTypeCategorySwitcher.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public static function make()
2020
->grouped()
2121
->options($enumClass)
2222
->default($enumClass::getDefaultValue()->value)
23+
// avoid dirty state issue for model
24+
->dehydrateStateUsing(fn ($state) => $state instanceof DocumentTypeCategory ? $state->value : $state)
2325
->required()
2426
->live()
2527
->colors(collect($enumClass::cases())->mapWithKeys(fn (DocumentTypeCategory $enumClass): array => [$enumClass->value => $enumClass->getColor()])->all())

src/Filament/Resources/DocumentTypes/Schemas/DocumentTypeForm.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ protected static function getShowAsTableFormComponent()
100100
->label(__('inspirecms::resources/document-type.show_as_table.label'))
101101
->validationAttribute(__('inspirecms::resources/document-type.show_as_table.validation_attribute'))
102102
->inlineLabel()
103-
->default(false)
104-
->live();
103+
->default(false);
105104
}
106105
}

0 commit comments

Comments
 (0)