aor-dependent-input
aor-dependent-input copied to clipboard
Dependent input when both resources are based on the REST client and have a 'belongsTo' relationship?
Hi,
I checked your example with your outer fetch, but I do not understand how to achieve a dependent input for a sub-resource, through AOR stateless functions (or not). The use case is that we want the "subCategories" field to be populated based on the "categories" field, to which there is a 'belongsTo' relationship.
<Create title={<TitleCreate />}{...props}>
<SimpleForm validate={validateCreateEdit}>
<ReferenceInput label="CATEGORY" source="cat_id" reference="categories" allowEmpty
perPage={100}
sort={{field: 'name', order: 'ASC'}}
>
<SelectInput optionText="name" />
</ReferenceInput>
<ReferenceInput label="SUBCATEGORY" source="subCat_id" reference="subCategories" allowEmpty
perPage={100}
sort={{field: 'name', order: 'ASC'}}
>
<SelectInput optionText="name" />
</ReferenceInput>
</SimpleForm>
</Create>
This is the relationship:
"relations": {
"category": {
"type": "belongsTo",
"model": "category",
"foreignKey": "cat_id"
}
}
````
I do not understand how this can be done based on the above generic AOR code.
Thanks for any hints or added documentation!
@djhi Is it possible to let me know if this is supported?