【问题标题】:Using SimpleForm inside DataGrid and ReferenceManyField | react-admin在 DataGrid 和 ReferenceManyField 中使用 SimpleForm |反应管理员
【发布时间】:2020-05-01 09:41:11
【问题描述】:

实际上,我尝试在 Datagrid 和 ReferenceManyField 中使用 SimpleForm 来显示连接表并更改此数据。显示数据和删除工作非常好,但每次我点击保存我都会收到以下错误:

`

Uncaught TypeError: onSave.current is not a function
    at submit (FormWithRedirect.js:86)
    at Object.submit (final-form.es.js:1296)
    at handleSubmit (react-final-form.es.js:264)
    at FormWithRedirect.js:121
    at handleClick (SaveButton.js:57)

`

我的实际代码:

<Edit {...props}>
        <SimpleShowLayout>
            <DateField source="date" />
            <ReferenceField label="Location" source="LocationID" reference="locations">
                <TextField source="name" />
            </ReferenceField>
            <ReferenceField label="Employee" source="EmployeeID" reference="employees">
                <TextField source="first_name" />
            </ReferenceField>
            <ReferenceManyField
                label="Customers"
                reference="bookings"
                target="data"
            >
                <Datagrid>
                    <SimpleForm>
                        <TextInput label="Vorname" source="customer.first_name" />
                        <TextInput label="Nachname" source="customer.last_name" />

                        <BooleanInput label="Anwesend" source="present" />
                    </SimpleForm>
                </Datagrid>
            </ReferenceManyField>
        </SimpleShowLayout>
    </Edit>

【问题讨论】:

  • 你的代码中的 onsave 函数在哪里?

标签: javascript reactjs react-admin


【解决方案1】:

根据文档,SimpleForm 应与 CreateEdit 父组件一起使用,因为它们将 savesaving 传递给 SimpleForm

source

您也可以尝试编写您的自定义onSave 函数并管理saving 状态。

<SimpleForm save={onSave} saving={saving}>

【讨论】:

  • 啊抱歉我没有复制整个代码我的错误。我已经更新了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-12-17
  • 2018-07-31
  • 2021-08-20
  • 2018-10-02
  • 1970-01-01
  • 1970-01-01
  • 2021-12-25
相关资源
最近更新 更多