I am using read-admin. https://marmelab.com/react-admin . I have a ReferenceArrayInput field named "Members" for selecting multiple values. I also have a RadioButtonGroupInput named "Manager" whose choices depend upon the values selected for "Members" i.e Manager can only be one of the members. How do I display only the selected members as options in Manager field? I used FormDataConsumer to get current form values and use the members as choices in manager field. But it shows all the operators as choices.
Here is my file.jsx
export const MyCreate = (props) => {
return (
<Create {...props}>
<SimpleForm>
<ReferenceArrayInput
source="members"
reference="operator"
label="Members"
>
<SelectArrayInput optionText='name'/>
</ReferenceArrayInput>
<FormDataConsumer>
{({ formData, ...rest }) => (
<ReferenceInput
source="manager"
label="Manager"
reference="operator"
>
<RadioButtonGroupInput
optionText="name"
choices={formData.members}
/>
</ReferenceInput>
)}
</FormDataConsumer>
</SimpleForm>
</Create>
)
}
Try this: