简体   繁体   English

antd PopConfirm 确认后如何提交antd 表单?

[英]How to submit the antd form onconfirmation of antd PopConfirm?

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?我有一个 antd 表单,我在上面检查输入的日期是否是过去的日期,然后我用 antd PopConfirm 显示弹出窗口,如果用户在 PopConfirm 中按“是”,我想提交表单,我该如何实现?

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>
// 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();
   }

look like看起来像

                        <Popconfirm
                      placement='top'
                      title='Bạn có chắc chắn muốn lưu lại thông tin đã sửa?'
                      onConfirm={() => {
                        form.submit();
                      }}
                      okText='Ok'
                      cancelText='Hủy'
                    >
                      <Button
                        type='text'
                        style={{ color: '#004EBC', padding: '0px 8px' }}
                        htmlType='submit'
                      >
                        Lưu
                      </Button>
                    </Popconfirm>
                            <Popconfirm
                                title='Are you sure to delete this task?'
                                onConfirm={() => {
                                    if ({ confirm }) {
                                        deletePetugas(petugas.id);
                                        message.success('Click on Yes');
                                    }
                                }}
                                onCancel={cancel}
                                type='primary'
                                okText='Yes'
                                cancelText='No'>
                                <Link to='#'>Delete</Link>
                            </Popconfirm>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM