KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
We are using Symfony2 to create an API. When updating a record, we expect the JSON input to represent a serialized updated entity. The JSON data will not contain some fields (for instance, CreatedAt should be set only once when the entity is created - and never updated). For instance, here is an example JSON PUT request: {"id":"1","name":"anyname","description":"anydescription"} Here is the PHP code on the Controller that should update the entity according to the JSON above (we are using JMS serializer Bundle): $supplier = $serializer->deserialize( $this->get('request')->getContent(), 'WhateverEntity', 'json' ); The EntityManger understands (correctly) that this is an update request (in fact, a SELECT query is implicitly triggered). The EntityManager also guess (not correctly) that CreatedAt property should be NULLified - it should instead keep the previous one. How to fix this issue?
Tags (comma-separated)
Save Edits
Cancel