Formik: How to Use submitForm as props from higher level

Created on 16 Jul 2019  路  3Comments  路  Source: formium/formik

馃悰 Bug report

Parent container has Save button to handle form changes (child).

Current Behavior

Using withFormik(), how to avoid

Expected behavior

Reproducible example


https://codesandbox.io/s/withformik-codesandbox-template-vz1yu

Suggested solution(s)

Additional context

Your environment

| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 1.5. 7
| React | 16.8.6
| TypeScript |
| Browser |
| npm/Yarn | 10.15.0
| Operating System | windows

stale

Most helpful comment

@prajavk this is not a formik issue. When you want to submit a form via button outside form childs it has the following steps to do.
1- Set your form an "id" attribute
2- After that set button attribute "form" with your form id name

i.e

Codesandbox link

All 3 comments

@prajavk this is not a formik issue. When you want to submit a form via button outside form childs it has the following steps to do.
1- Set your form an "id" attribute
2- After that set button attribute "form" with your form id name

i.e

Codesandbox link

Please also read about ref forwarding. https://reactjs.org/docs/forwarding-refs.html

Closing due to long inactivity

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jungwoo-An picture Jungwoo-An  路  3Comments

jordantrainor picture jordantrainor  路  3Comments

green-pickle picture green-pickle  路  3Comments

dfee picture dfee  路  3Comments

pmonty picture pmonty  路  3Comments