Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

553
Vistas
Antd form form.getFieldError() returns an empty array onFinish although the filed has an error

I have a form created with antd. I have some custom fields that I use in Form.Item as a child. The problem is when I submit the form, the field has an error and the message is shown by Form.Item. But I can pass the error to my custom field to change the border color.

I tried to pass the error using form.getFieldError(), in which the form is a form instance. But it returns an empty array and only when I change a state the array will find value.

How can I pass the error to my element instantly as the message shows?

this is the code I'm using and the image below it is the result at submit.

<Form.Item
     label="Origin Country"
     name="From"
     className="flex-1"
     rules={[{ required: true }]}
     initialValue={initialValue?.initialOriginCountry?.name}
>
     <SearchSelectCountry
         minLetter={1}
         placeholder="Origin Country"
         onSearch={(values) => onCountriesSearch(values, 'origin')}
         options={originCountries}
         onChange={(value) => handleChangeOriginContry(value)}
         initialValue={originSelectedCountry}
         error={form.getFieldError('From')?.length > 0}
      />
</Form.Item>

enter image description here

And this is when I change a state and the array fills up and error passes down to the child and the border color changes:

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda