您想要做的是在Admin On Rest面板的Create操作中创建FileInput。
以下是我的创建操作定义。
import React from 'react';
import {Create, SimpleForm, TextInput, ReferenceInput, SelectInput, FileInput, FileField} from 'admin-on-rest';
export default (props) => (
<Create {...props}>
<SimpleForm>
<TextInput source="name" />
<ReferenceInput label="Project" source="projectId" reference="projects" allowEmpty>
<SelectInput optionText="name"/>
</ReferenceInput>
</SimpleForm>
<FileInput source="files" label="Related files" accept="application/pdf">
<FileField source="src" title="title" />
</FileInput>
</Create>
);
它会引发https://pastebin.com/E6zae4k6
等错误你有什么想法吗?
答案 0 :(得分:0)
import React from 'react';
import {Create, SimpleForm, TextInput, ReferenceInput, SelectInput, FileInput, FileField} from 'admin-on-rest';
export default (props) => (
<Create {...props}>
<SimpleForm>
<TextInput source="name" />
<ReferenceInput label="Project" source="projectId" reference="projects" allowEmpty>
<SelectInput optionText="name"/>
</ReferenceInput>
<FileInput source="files" label="Related files" accept="application/pdf">
<FileField source="src" title="title" />
</FileInput>
</SimpleForm>
</Create>
);