Home > OS >  How to submit the antd form onconfirmation of antd PopConfirm?
How to submit the antd form onconfirmation of antd PopConfirm?

Time:11-10

I have an antd Form on which i checked if entered date is past date then i show the Popup with antd PopConfirm and if user press 'Yes' in PopConfirm, i want to submit the form, how can i achieve this?

Below is my code :

<PopConfirm
              onConfirm={() => {
                
              }}
              cancelText={'No'}
              okText={'Yes'}
              disabled={!isPastDate}
              title={'Do you wish to continue with past date?'}
            >
              <Button type="primary" label="Save" htmlType="submit" />
            </PopConfirm>

CodePudding user response:

// your component
(props) => {

  const [form] = Form.useForm();
  ...
  return (
     <Form
      layout='vertical'
      form={form}
      scrollToFirstError
      onFinish={onSubmitHandler}

      ... 

     // try removing the Button properties so it does not auto submit
   // in popup confirm
   onConfirm={() => {
      form.submit();
   }
  • Related