[英]Get form data in handleSubmit
Can anyone help me?任何人都可以帮助我吗?
In the Admin-on-rest framework, I want to write a handleSubmit in SimpleForm.在 Admin-on-rest 框架中,我想在 SimpleForm 中编写一个 handleSubmit。 How to get form data in handleSubmit.
如何在handleSubmit中获取表单数据。
I have two file input: FileInput
and ImageInput
and one TextInput
.我有两个文件输入:
FileInput
和ImageInput
和一个TextInput
。 I want to send files and text to the server after submitting the form.我想在提交表单后将文件和文本发送到服务器。 The input files use the react-dropzone and don't send the files to the server after submitting.
输入文件使用 react-dropzone 并且提交后不将文件发送到服务器。
I can not find any example for this.我找不到任何例子。
let filex;
<SimpleForm handleSubmit={(data)=>{ console.log(data); }}>
<TextInput label="عنوان کتاب" source="title" validate={required} />
<RichTextInput label="توضیحات" source="description" toolbar={[
['bold', 'italic', 'underline', 'link'],
[{ 'direction': 'rtl' }],
[{ 'align': [] }],
['clean'],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
]} validate={required} />
<ImageInput source="bookImg"
label="تصویر کتاب"
input={{
value: filex,
onChange: (file) => {
filex = file;
}
}}
validate={required} accept="image/*">
<ImageField source="src" title="title" />
</ImageInput>
<FileInput source="bookPdf" label="فایل کتاب" validate={required} accept="application/pdf">
<FileField source="src" title="title" />
</FileInput>
</SimpleForm>
This is covered in the documentation:这在文档中有介绍:
End of the FileInput section: https://marmelab.com/admin-on-rest/Inputs.html#fileinput FileInput 部分结束: https : //marmelab.com/admin-on-rest/Inputs.html#fileinput
And on the restClient: https://marmelab.com/admin-on-rest/RestClients.html#decorating-your-rest-client-example-of-file-upload在 restClient 上: https ://marmelab.com/admin-on-rest/RestClients.html#decorating-your-rest-client-example-of-file-upload
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.