Skip to content

Commit ff0d93a

Browse files
committed
refactor: extract getFieldValidationRules() for subclass override
Allow form component subclasses to filter or modify validation rules before they are applied. FileUpload-based components need to strip the 'string' rule that DatabaseFieldConstraints adds for string_value columns, since FileUpload submits TemporaryUploadedFile objects.
1 parent e91c2c5 commit ff0d93a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Filament/Integration/Base/AbstractFormComponent.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function configure(
6666
filled($state)
6767
)
6868
->required($this->validationService->isRequired($customField))
69-
->rules($this->validationService->getValidationRules($customField))
69+
->rules($this->getFieldValidationRules($customField))
7070
->columnSpan($customField->width->getSpanValue())
7171
->when(
7272
FeatureManager::isEnabled(CustomFieldsFeature::FIELD_CONDITIONAL_VISIBILITY) &&
@@ -123,6 +123,12 @@ private function applyVisibility(
123123
: $field->live()->visibleJs($jsExpression);
124124
}
125125

126+
/** @return array<int, mixed> */
127+
protected function getFieldValidationRules(CustomField $customField): array
128+
{
129+
return $this->validationService->getValidationRules($customField);
130+
}
131+
126132
/**
127133
* Apply settings dynamically to any Filament component
128134
*/

0 commit comments

Comments
 (0)