Locastic / ApiPlatformTranslationBundle

Translation bundle for ApiPlatform based on Sylius translation
MIT License
85 stars 28 forks source link

validation of the fields of my entity with PUT REQUEST #45

Open kevinG73 opened 3 years ago

kevinG73 commented 3 years ago

Hello , my problem it's with the validation of the fields of my entity. Example: in my class

  /**
  * @ORM \ Entity ()
  * @UniqueEntity (fields = {"locale", "title"})
  **/
  class CategoryTranslation extends AbstractTranslation

i used the UniqueEntity annotation to prevent using the same word more two times with same local value, with my POST requests there are not problem but when I try to use PUT requests the bundle does not UPDATE the data, it removes the records to insert new values so I get this error : "detail": "translations [fr] .locale: This value is already used."

when I send this json to my endpoint:

 {
   "translations": [
     {
       "title": "natures",
       "locale": "fr"
     },
      {
       "title": "nature",
       "locale": "en"
     }
   ]
}

someone can give any hints ? thank you in advance

paullla commented 3 years ago

Hi @kevinG73 ,

Did you try using PATCH instead of PUT for editing?

paullla commented 3 years ago

@kevinG73 I forgot to mention, when editing translations, you need to send the id of each object in order for it to be updated.