MW00
MW00

Reputation: 85

Using SimpleForm inside DataGrid and ReferenceManyField | react-admin

actually i try to use a SimpleForm inside a Datagrid and ReferenceManyField to show a joined table and also change this data. Showing the data and deleting works pretty fine but everytime i click on Save i get the following Error:

`

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)

`

My actual Code:

<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>

Upvotes: 4

Views: 1449

Answers (1)

J&#243;zef Podlecki
J&#243;zef Podlecki

Reputation: 11283

According to docs SimpleForm should be used with Create and Edit parent component as they pass save and saving to SimpleForm.

source

You can also try write your custom onSave function and manage saving state.

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

Upvotes: 2

Related Questions