Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Dependent input when both resources are based on the REST client and have a 'belongsTo' relationship? #22

Open
afilp opened this issue Dec 21, 2017 · 1 comment

Comments

@afilp
Copy link

afilp commented Dec 21, 2017

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!
@afilp
Copy link
Author

afilp commented Jan 3, 2018

@djhi Is it possible to let me know if this is supported?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant