Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
Formik get same name field input

When I click add input, it brings another one from the same input, but this time the name property is the same. I tried to put it in the photos array with different names. but I couldn't. A string expression is entered into the photos input. How can I collect these inputs into photos:[] with formik

const{handleSubmit,handleChange,handleBlur,errors,touched} = useFormik({
    initialValues:{
      title:"",
      price:"",
      description:"",
      photos:[],
   
    },
    onSubmit:(values)=>{
     
     console.log(values);
    
     
    }
  })


{fields.map((field, index) => (
              <Form.Item
                
                label={"Product Image"}
                required={false}
                key={field.key}
              >
                <Form.Item
                  {...field}
                  
                  noStyle
                >
                  <Input name={fields.length > 1 ? `photos[${fields.length}]` : "photos[0]"} onChange={handleChange} onBlur={handleBlur} placeholder="Enter a image url..." style={{ width: '60%' }} />
                </Form.Item>
                {fields.length > 1 ? (
                  <MinusCircleOutlined
                    className="ms-1 dynamic-delete-button"
                    onClick={() => remove(field.name)}
                  />
                ) : null}
              </Form.Item>
            ))}
<Form.Item className="text-center">
              <Button
                type="dashed"
                onClick={fields.length < 5 ? () => add() : null}
              
                
              >
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!