Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit b662451

Browse files
committed
Add onSubmit function to Form
1 parent 5ebd805 commit b662451

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

components/molecules/Form/Form.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,22 @@ import cn from 'classnames'
1313
* @param {object} props.formDefaults Formik default data.
1414
* @param {string|number} props.id Form id.
1515
* @param {object} props.validationSchema Yup validation schema object.
16+
* @param {function} props.onSubmit Function to execute when form is submitted
1617
* @return {Element} The Form component.
1718
*/
1819
export default function Form({
1920
children,
2021
className,
2122
formDefaults,
2223
id,
23-
validationSchema
24+
validationSchema,
25+
onSubmit
2426
}) {
2527
return (
2628
<Formik
2729
initialValues={formDefaults}
2830
validationSchema={validationSchema}
29-
onSubmit={(values, {setSubmitting}) => {
30-
setTimeout(() => {
31-
alert(JSON.stringify(values, null, 2))
32-
setSubmitting(false)
33-
}, 400)
34-
}}
31+
onSubmit={onSubmit}
3532
>
3633
<FormikForm id={id} className={cn(styles.form, className)}>
3734
{children}
@@ -46,7 +43,8 @@ Form.propTypes = {
4643
className: PropTypes.string,
4744
formDefaults: PropTypes.object,
4845
id: PropTypes.string,
49-
validationSchema: PropTypes.object
46+
validationSchema: PropTypes.object,
47+
onSubmit: PropTypes.function
5048
}
5149

5250
Form.defaultProps = {

0 commit comments

Comments
 (0)