aor-dependent-input icon indicating copy to clipboard operation
aor-dependent-input copied to clipboard

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

Open afilp opened this issue 6 years ago • 1 comments

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 avatar Dec 21 '17 21:12 afilp

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

afilp avatar Jan 03 '18 01:01 afilp