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

231
Views
Antd with formik setFieldValue

There is a Antd table with data, when i click to button "Change", the entire line with data is passed to the function in the form of an object, now it remains to insert data into the fields, but I can't, what should I do?

How set data to antd input using outside function?

I can do it with .map (), but it seems more appropriate to me to use formik

enter image description here

enter image description here

const BankForm = (props) => {
        const [form] = Form.useForm();
        //show close form
        const columns = [
      ...MY columns
          {
            title: "Действие",
            key: "action",
            fixed: "right",
            render: (text, record) => (
              <Space size="middle"

              I clink to Button and all data of row go to ChangeBank(record)

                <a onClick={() => ChangeBank(record)}> Изменить</a>
            
              </Space>
            ),
          },
        ];
        const formik = useFormik({
          initialValues: {
            name_bank: "",
         
          },
          validate,
          onSubmit: (values) => {
          },
        });
      //my function to set data to form
        let ChangeBank = (record) => {
          formik.setFieldValue("name_bank", record.name_bank);
        };

        return (
            <div className={clas.tableBlock_header}>
      my form
         
              <Form
                form={form}
                layout="vertical"
                hideRequiredMark
                onFinish={formik.handleSubmit}
              >
                    <Form.Item
                      name="name_bank"
                      label="Название банка"
                      rules={[{ required: true, message: "Введите название банка" }]}
                    >
                      <Input value={formik.values.name_bank} name="name_bank" />
                    </Form.Item>
              </Form>
        );
      };

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to set values in antd form fields with formik, dont give the name Form.item

AND if you want use antd with formik, and you need validaite your inputs just download Yup. Dont use antd menthods. Yup with formik

          <Form
            form={form}
            layout="vertical"
            hideRequiredMark
            onFinish={formik.handleSubmit}
          >
                <Form.Item
                 
                  label="Название банка"
                  rules={[{ required: true, message: "Введите название банка" }]}
                >
                  <Input value={formik.values.name_bank} name="name_bank" />
                </Form.Item>
          </Form>**strong text**
about 4 years ago · Juan Pablo Isaza Report
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!