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

546
Views
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
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!