Formik hidden field not showing up on submit and a way to set initial values dynamically

Viewed 921

I'm using formik ArrayFields to generate a set of questions based on user input.

<Field
    type="hidden"
    value={something.text}
    name={`friends[${index}].something`}
/>
<Field
   type="hidden"
   value={something.type}
   name={`friends[${index}].type`}
/>
<Field
   className={classes.textField}
   component={TextField}
   label={something.text}
   value=" "
   name={`friends[${index}].somethinelse`}
/>

on submit I want the hidden fields to show as {name:value} how would I do that as that is currently not how they work. Also I would like a way to have a default value for my fields to submit as if they are untouched at the moment having a value = " " does not allow me to edit the field; onChange = "formik.handleChange" does not work as well, on change returns as undefined will post the exact error if someone is interested. thanks for any help

1 Answers

I fixed this by populating the formik values before rendering the fields with dummy data

Related