Core: [QUESTION] How to save nested relation?

Created on 23 Jun 2017  路  6Comments  路  Source: api-platform/core

For example I have Brand:

{
  "id": 0,
  "name": "string",
  "website": "string",
  "keywords": [
    {
      "language": "string",
      "keyword": "string"
    }
  ],
  "translations": [
    {
      "id": 0,
      "language": "string",
      "website": "string",
      "name": "string",
      "description": "string"
    }
  ]
}

As you can see I have relations keywords and translations and if I try to save translations with this array:

{"translations":{"1":{"language":"en","description":"asf"}},"name":"Asfasf","website":null}

I got an error Nested documents for attribute \u0022translations\u0022 are not allowed. Use IRIs instead.

Most helpful comment

@VeeeneX for me you need to have the same denormalization groups one the entities and a relation with cascade persit

All 6 comments

You will have to create the relation before, and use its URI.

@sroze And can be done this in feature by one call?

@VeeeneX for me you need to have the same denormalization groups one the entities and a relation with cascade persit

@Tim59 indeed, this is a supported use case.

Thanks

@sroze How do I use the IRI?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DenisVorobyov picture DenisVorobyov  路  3Comments

soyuka picture soyuka  路  3Comments

tezvi picture tezvi  路  3Comments

mahmoodbazdar picture mahmoodbazdar  路  3Comments

silverbackdan picture silverbackdan  路  3Comments