{"action":"created","issue":{"url":"https://api.github.com/repos/symfony-cmf/SeoBundle/issues/275","repository_url":"https://api.github.com/repos/symfony-cmf/SeoBundle","labels_url":"https://api.github.com/repos/symfony-cmf/SeoBundle/issues/275/labels{/name}","comments_url":"https://api.github.com/repos/symfony-cmf/SeoBundle/issues/275/comments","events_url":"https://api.github.com/repos/symfony-cmf/SeoBundle/issues/275/events","html_url":"https://github.com/symfony-cmf/SeoBundle/issues/275","id":133700512,"number":275,"title":"Don't persist seoMetadata on Sonata Admin update","user":{"login":"xmon","id":4361296,"avatar_url":"https://avatars.githubusercontent.com/u/4361296?v=3","gravatar_id":"","url":"https://api.github.com/users/xmon","html_url":"https://github.com/xmon","followers_url":"https://api.github.com/users/xmon/followers","following_url":"https://api.github.com/users/xmon/following{/other_user}","gists_url":"https://api.github.com/users/xmon/gists{/gist_id}","starred_url":"https://api.github.com/users/xmon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xmon/subscriptions","organizations_url":"https://api.github.com/users/xmon/orgs","repos_url":"https://api.github.com/users/xmon/repos","events_url":"https://api.github.com/users/xmon/events{/privacy}","received_events_url":"https://api.github.com/users/xmon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-15T12:29:28Z","updated_at":"2016-03-05T23:09:22Z","closed_at":"2016-03-05T23:09:22Z","body":"Hi,\r\n\r\nI'm trying to integrate **SeoBundle 1.1.2** in my project with **Symfony 2.7.9**. and **SonataAdminBundle 2.3.7.**\r\nI use **Doctrine ORM**, I have implemented in my Entity correctly seoMetaData object.\r\n\r\nWhen I create a new record, the information in the fields of seoMetaData, saved correctly, but when editing this record, the values of these fields are **not saved to the database in the update**.\r\n\r\nDo you have any idea what could be the problem?\r\n\r\nThank you so much for everything.\r\n"},"comment":{"url":"https://api.github.com/repos/symfony-cmf/SeoBundle/issues/comments/192756855","html_url":"https://github.com/symfony-cmf/SeoBundle/issues/275#issuecomment-192756855","issue_url":"https://api.github.com/repos/symfony-cmf/SeoBundle/issues/275","id":192756855,"user":{"login":"WouterJ","id":749025,"avatar_url":"https://avatars.githubusercontent.com/u/749025?v=3","gravatar_id":"","url":"https://api.github.com/users/WouterJ","html_url":"https://github.com/WouterJ","followers_url":"https://api.github.com/users/WouterJ/followers","following_url":"https://api.github.com/users/WouterJ/following{/other_user}","gists_url":"https://api.github.com/users/WouterJ/gists{/gist_id}","starred_url":"https://api.github.com/users/WouterJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WouterJ/subscriptions","organizations_url":"https://api.github.com/users/WouterJ/orgs","repos_url":"https://api.github.com/users/WouterJ/repos","events_url":"https://api.github.com/users/WouterJ/events{/privacy}","received_events_url":"https://api.github.com/users/WouterJ/received_events","type":"User","site_admin":false},"created_at":"2016-03-05T23:09:22Z","updated_at":"2016-03-05T23:09:22Z","body":"Thanks for your report and help to debug this issue @xmon!\r\n\r\nThis is not a bug in the CmfSeoBundle or SonataAdminBundle, but rather the way Doctrine ORM works with objects. You can see [this stackoverflow answer](http://stackoverflow.com/a/15488230/1149495) for some detailed information. In short, Doctrine doesn't discover changes when you edit properties of an object by reference.\r\n\r\nAs the Symfony forms handles objects (in this case the `SeoMetadata` instance) by reference by default, doctrine won't know anything has changed. In order to fix this, force Symfony forms to use the setter + getter explicitly:\r\n\r\n```php\r\n$formMapper\r\n    ->with('SEO', array('class' => 'col-md-3'))\r\n        ->add('seoMetadata', 'seo_metadata', array('by_reference' => false))\r\n    ->end()\r\n;\r\n```\r\n\r\nThis solved the problem in my test application, so I think it should solve it in your case as well. However, if you still can't make it work, just leave a comment and we'll reopen this issue."}}