Skip to content

Commit

Permalink
fix attribute is null
Browse files Browse the repository at this point in the history
  • Loading branch information
wychoong committed May 24, 2024
1 parent bc92a62 commit 7b19a0e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/admin/src/Support/Forms/AttributeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ public function getFilamentComponent(Attribute $attribute): Component
$attribute->type
] ?? TextField::class;

return $fieldType::getFilamentComponent($attribute)->label(
$attribute->translate('name')
)
/** @var Component $component */
$component = $fieldType::getFilamentComponent($attribute);

return $component
->label(
$attribute->translate('name')
)
->formatStateUsing(fn ($state) => ($state ?: new $attribute->type))
->mutateDehydratedStateUsing(fn ($state) => ($state ?: new $attribute->type))
->required($attribute->required)
->default($attribute->default_value);
}
Expand Down

0 comments on commit 7b19a0e

Please sign in to comment.