{"action":"closed","issue":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/3059","labels_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/3059/labels{/name}","comments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/3059/comments","events_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/3059/events","html_url":"https://github.com/sonata-project/SonataAdminBundle/issues/3059","id":88696878,"number":3059,"title":"Sonata_admin_collection field update works, but add/remove finishes with \"success\" without changes","user":{"login":"alymdrictels","id":7284921,"avatar_url":"https://avatars.githubusercontent.com/u/7284921?v=3","gravatar_id":"","url":"https://api.github.com/users/alymdrictels","html_url":"https://github.com/alymdrictels","followers_url":"https://api.github.com/users/alymdrictels/followers","following_url":"https://api.github.com/users/alymdrictels/following{/other_user}","gists_url":"https://api.github.com/users/alymdrictels/gists{/gist_id}","starred_url":"https://api.github.com/users/alymdrictels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alymdrictels/subscriptions","organizations_url":"https://api.github.com/users/alymdrictels/orgs","repos_url":"https://api.github.com/users/alymdrictels/repos","events_url":"https://api.github.com/users/alymdrictels/events{/privacy}","received_events_url":"https://api.github.com/users/alymdrictels/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-16T11:20:21Z","updated_at":"2015-06-16T13:17:59Z","closed_at":"2015-06-16T13:17:59Z","body":"I've wasted far too many hours getting all the pieces to work so asking here is my last resort.\r\n\r\nI'm using three entities:\r\n\"Item\" ->oneToMany - ManyToOne<- \"OrderHasItem\" -> ManyToOne - OneToMany <- \"Order\"\r\n\r\nAll are set to cascade persist in their respective .yml files.\r\n\r\nUpdating existing items in the collection works properly, and the POST request includes the new item. When deleting, the _delete flag is added properly. However, no changes are persisted.\r\n\r\nTo rule out errors in my Entity mappings, I've tried re-generating all the classes using doctrine:generate:entities for the bundle namespace.\r\n\r\nHere are the files involved (yml omitted):\r\n\r\nOrder.php\r\n```\r\n    public function __construct()\r\n    {\r\n        $this->items = new \\Doctrine\\Common\\Collections\\ArrayCollection();\r\n    }\r\n\r\n    public function addItem(OrderBundle\\Entity\\OrderHasItem $items)\r\n    {\r\n        $this->items[] = $items;\r\n        return $this;\r\n    }\r\n\r\n    public function removeItem(OrderBundle\\Entity\\OrderHasItem $items)\r\n    {\r\n        $this->items->removeElement($items);\r\n    }\r\n\r\n\r\n    public function getItems()\r\n    {\r\n        return $this->items;\r\n    }\r\n```\r\nOrderHasItem.php\r\n```\r\n    public function setItem(OrderBundle\\Entity\\Item $item = null)\r\n    {\r\n        $this->item = $item;\r\n\r\n        return $this;\r\n    }\r\n\r\n    public function getItem()\r\n    {\r\n        return $this->item;\r\n    }\r\n```\r\n\r\nItem.php\r\n```\r\n    public function setOrderHasItem( OrderHasItem $orderhasitem )\r\n    {\r\n        $this->orderhasitem = $orderhasitem;\r\n    }\r\n\r\n    public function geOrderHasItem()\r\n    {\r\n        return $this->orderhasitem;\r\n    }\r\n```\r\n\r\nOrderAdmin.php\r\n```\r\n    /**\r\n     * @param FormMapper $formMapper\r\n     */\r\n    protected function configureFormFields(FormMapper $formMapper)\r\n    {\r\n        $formMapper\r\n            ->add('items', 'sonata_type_collection', array('required' => true,\r\n                'by_reference' => false,\r\n\r\n            ),\r\n                array('edit' => 'inline',\r\n                    'inline' => 'table'\r\n                ))\r\n```\r\n (etc.)\r\n\r\nOrderHasItemAdmin.php\r\n```\r\n    /**\r\n     * @param FormMapper $formMapper\r\n     */\r\n    protected function configureFormFields(FormMapper $formMapper)\r\n    {\r\n        $formMapper\r\n            ->add('item', 'sonata_type_model', array('required' => false, 'btn_add' => false, 'btn_delete' => true),\r\n            array('compound' => true, 'by_reference' => false, 'link_parameters' => array('provider' => 'order.admin.item', 'context' => 'orderhasitem'\r\n            ))) /* etc. */\r\n```\r\n\r\nIs the issue in my formMapper configuration, or do I need to add prePersist and preUpdate hooks to the OrderAdmin class? Is it necessary to modify the entities themselves?\r\n\r\nSo far I've found Sonata excellent and easy to use for relatively simple use cases, but I've found that things like embedded admins are one of the topics that should be covered better in the documentation."}}