I have a User Resource, which referenced by many other resources.
So I want to create a UserResourceInput :
import React from 'react';
import {ReferenceInput, SelectInput} from 'admin-on-rest';
const UserReferenceInput = (props) => (
<ReferenceInput reference="user" {...props}>
<SelectInput optionText="name"/>
</ReferenceInput>
);
UserReferenceInput.defaultProps = {
source: 'userId',
addLabel: true,
label: 'User'
};
export default UserReferenceInput;
And Use it in simple form like this:
ProductCreate = (props) => (
<Create {...props}>
<SimpleForm>
<TextInput source="title" />
<NumberInput source="price" />
<UserReferenceInput />
</SimpleForm>
</Create>
);
You are missing the source
prop on the ReferenceInput
. Hence, it can't find value for it. You can define it either inside the UserReferenceInput
directly or pass it as prop to the UserReferenceInput
in your form.
Edit
Don't use the addLabel
prop on the ReferenceInput
, it does not support it. Instead, apply it on the SelectInput
child.