Skip to content

Commit b9bb9fd

Browse files
committed
Fix for popup field validation
1 parent 43c02e7 commit b9bb9fd

File tree

1 file changed

+10
-1
lines changed
  • packages/firecms_core/src/components/EntityCollectionTable/internal/popup_field

1 file changed

+10
-1
lines changed

packages/firecms_core/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,15 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
224224
const formex = useCreateFormex<M>({
225225
initialValues: (entity?.values ?? {}) as EntityValues<M>,
226226
validation: (values) => {
227-
return validationSchema?.validate(values)
227+
return validationSchema?.validate(values, { abortEarly: false })
228+
.then(() => ({}))
229+
.catch((e) => {
230+
const errors: Record<string, string> = {};
231+
e.inner.forEach((error: any) => {
232+
errors[error.path] = error.message;
233+
});
234+
return errors;
235+
});
228236
},
229237
validateOnInitialRender: true,
230238
onSubmit: (values, actions) => {
@@ -339,6 +347,7 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
339347
}
340348
const form = <div
341349
className={`text-gray-900 dark:text-white overflow-auto rounded rounded-md bg-white dark:bg-gray-950 ${!open ? "hidden" : ""} cursor-grab max-w-[100vw]`}>
350+
342351
{internalForm}
343352

344353
{savingError &&

0 commit comments

Comments
 (0)