Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda