2

Can anyone help me?

In the Admin-on-rest framework, I want to write a handleSubmit in SimpleForm. How to get form data in handleSubmit.

I have two file input: FileInput and ImageInput and one 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.

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>
Ali Hesari
  • 1,821
  • 5
  • 25
  • 51
  • Can you explain your use case first ? – Gildas Garcia Apr 12 '18 at 08:13
  • @Gildas I have two file input: `FileInput` and `ImageInput` and one `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. – Ali Hesari Apr 12 '18 at 09:24

1 Answers1

-1

This is covered in the documentation:

End of the FileInput section: 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

Gildas Garcia
  • 6,966
  • 3
  • 15
  • 29