aboutsummaryrefslogtreecommitdiff
path: root/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx')
-rw-r--r--packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx b/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx
index d8877333c..87c4c43fb 100644
--- a/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx
+++ b/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx
@@ -41,10 +41,12 @@ export function FormProvider<T>({
children,
initialValue,
onUpdate,
+ onSubmit,
computeFormState,
}: {
initialValue?: Partial<T>;
onUpdate?: (v: Partial<T>) => void;
+ onSubmit: (v: T) => void;
computeFormState?: (v: T) => FormState<T>;
children: ComponentChildren;
}): VNode {
@@ -58,7 +60,15 @@ export function FormProvider<T>({
<FormContext.Provider
value={{ initialValue, value, onUpdate, computeFormState }}
>
- <form>{children}</form>
+ <form
+ onSubmit={(e) => {
+ e.preventDefault();
+ //@ts-ignore
+ onSubmit(value.current);
+ }}
+ >
+ {children}
+ </form>
</FormContext.Provider>
);
}