diff --git a/src/pages/complex-forms-with-formik.md b/src/pages/complex-forms-with-formik.md new file mode 100644 index 0000000..cf304ab --- /dev/null +++ b/src/pages/complex-forms-with-formik.md @@ -0,0 +1,263 @@ +--- +title: Highly complex forms with Formik +date: 2019-04-24 +updated: +description: + I fell deeper in love with Formik after building the most complex form + I've encountered. +tags: javascript, react, formik +cover_image: https://i.imgur.com/rLxAGsz.jpg +--- + +(Image credit: +[Leonel Fernandez](https://unsplash.com/photos/REZp_5-2wzA)) + +Formik is a wonderful library. When combined with the Yup validation +library, it becomes almost trivial to handle touched inputs and +validation—even with large forms with many different types of fields. + +I used Formik and Yup for a particularly complex form. It needed 1 form +to input some metadata about a transaction, and a sub-form of one of 12 +different varieties—called an "operation" here. The backend for this +system accepts up to 200 operations per transaction, so this form needed +to reflect that. + +Some additional constraints I was working under: over the next several +years, it's likely that the validation rules will need to be adjusted an +updated, so another design goal was ease of maintenance in that regard. + +# Creating a sub-form + +The fundamental problem with a sub-form is that HTML doesn't allow +`