const CreateForm = Form.create()(props => {
const { modalVisible, form, handleAdd, handleModalVisible,formValues } = props;
const { getFieldsValue, getFieldProps } = form;
const okHandle = () => {
form.validateFields((err, fieldsValue) => {
console.log(err)
console.log(fieldsValue)
if (err) return;
form.resetFields();
handleAdd(fieldsValue);
});
};
form.imgUrl = "";
const onOkUpload = (res)=>{
form.imgUrl = res.id||"";
console.log(form.imgUrl)
}
const validator = (rule, value, callback) => {
console.log(form.imgUrl)
if(!form.imgUrl){
callback("")
}
callback()
}
return (
<Modal
title=""
visible={modalVisible}
onOk={okHandle}
onCancel={() => handleModalVisible()}
>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="">
{form.getFieldDecorator("img", {
valuePropName: "fileList",
getValueFromEvent:normFile,
})(<UploadOne onOk={onOkUpload} />)}
</FormItem>
</Modal>
(< UploadOne onOk= {onOkUpload} / > upload component ok upload url, but form doesn"t know how to verify