scroll to required fields in trail edit
Former-commit-id: 4d4c11bd86760b9ee98b7db188df279cf71e82d1
This commit is contained in:
@@ -28,6 +28,7 @@ export const createForm = (config) => {
|
||||
const validationSchema = config.validationSchema;
|
||||
const validateFunction = config.validate;
|
||||
const onSubmit = config.onSubmit;
|
||||
const onError = config.onError;
|
||||
|
||||
const getInitial = {
|
||||
values: () => util.cloneDeep(initialValues),
|
||||
@@ -133,6 +134,7 @@ export const createForm = (config) => {
|
||||
return clearErrorsAndSubmit(values);
|
||||
} else {
|
||||
errors.set(error);
|
||||
onError(error)
|
||||
isSubmitting.set(false);
|
||||
}
|
||||
})
|
||||
@@ -154,7 +156,7 @@ export const createForm = (config) => {
|
||||
yupErrors.inner.map((error) =>
|
||||
util.set(updatedErrors, error.path, error.message),
|
||||
);
|
||||
|
||||
onError(updatedErrors)
|
||||
errors.set(updatedErrors);
|
||||
}
|
||||
isSubmitting.set(false);
|
||||
|
||||
@@ -61,6 +61,7 @@ type FormState<Inf = Record<string, any>> = {
|
||||
declare function createForm<Inf = Record<string, any>>(formProperties: {
|
||||
initialValues: Inf;
|
||||
onSubmit: (values: Inf) => any | Promise<any>;
|
||||
onError?: (errors: Record<string, any>) => any | Promise<any>;
|
||||
validate?: (values: Inf) => any | undefined;
|
||||
validationSchema?: ObjectSchema<any>;
|
||||
}): FormState<Inf>;
|
||||
|
||||
Reference in New Issue
Block a user