ReferenceField和ReferenceInput

时间:2017-06-29 08:25:40

标签: admin-on-rest

(抱歉我的英文。如果你纠正我的错误会很棒)。 我有一个产品列表并创建产品/编辑产品页面。 每个产品都有一组属性。 每组属性都有属性。 怎么办下一个: 当我在创建或编辑时为产品选择一组属性时,在表单(创建产品/编辑产品)中将添加带有属性标签的新TextInputs。

这是我的产品:

products: [
{
  id: 1,
  title: 'title1',
  description: 'description1',
  shortDescription: 'shortDescription1',
  seo: {
    title: 'seotitle1',
    description: 'description1',
    keywords: ['keywords1'],
  },
  price: 428,
  parentCategories: [1],
  images: [
    {
      id: 123,
      url: 'urlImage1',
      title: 'urlTitle1',
    },
  ],
  isItActive: true,
  creationDate: '2008-04-01T14:57:42.105Z',
  modificationDate: '2009-04-01T14:57:42.105Z',
  setOfAttributes: 1,
}, {
  id: 2,
  title: 'title2',
  description: 'description2',
  shortDescription: 'shortDescription2',
  seo: {
    title: 'seotitle2',
    description: 'description2',
    keywords: ['keywords2'],
  },
  price: 418,
  parentCategories: [2],
  images: [
    {
      id: 122,
      url: 'urlImage2',
      title: 'urlTitle2',
    },
  ],
  isItActive: false,
  creationDate: '2010-04-01T14:57:42.105Z',
  modificationDate: '2011-04-01T14:57:42.105Z',
  setOfAttributes: 3,
}, {
  id: 3,
  title: 'title3',
  description: 'description3',
  shortDescription: 'shortDescription3',
  seo: {
    title: 'seotitle3',
    description: 'description3',
    keywords: ['keywords3'],
  },
  price: 423,
  parentCategories: [3],
  images: [
    {
      id: 323,
      url: 'urlImage3',
      title: 'urlTitle3',
    },
  ],
  isItActive: true,
  creationDate: '2012-04-01T14:57:42.105Z',
  modificationDate: '2013-04-01T14:57:42.105Z',
  setOfAttributes: 2,
},

],

这是我的attrubutes:

attributes: [
{
  id: 1,
  name: 'asdgsd',
  title: 'qwed',
  type: 'список',
  showInFilter: null,
},
{
  id: 2,
  name: 'zxcv',
  title: 'fkf',
  type: 'текстовое поле',
  showInFilter: null,
},
{
  id: 3,
  name: 'asdkd',
  title: 'rczh',
  type: null,
  showInFilter: null,
},

],

以下是一组属性:

setOfAttributes: [
{
  id: 1,
  title: 'Набор 1',
  attributes: [1, 3],
},
{
  id: 2,
  title: 'Набор 2',
  attributes: [3, 1, 2],
},
{
  id: 3,
  title: 'Набор 3',
  attributes: [2, 3],
},

],

我能做到这一点(productsEdit.jsx):

<ReferenceField source="setOfAttributes" reference="setOfAttributes" linkType={false}>
     <ReferenceArrayField source="attributes" reference="attributes">
         <SingleFieldList>
            <ChipField source="title" />
         </SingleFieldList>
     </ReferenceArrayField>
</ReferenceField>

0 个答案:

没有答案