{"action":"opened","issue":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2857","labels_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2857/labels{/name}","comments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2857/comments","events_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/2857/events","html_url":"https://github.com/sonata-project/SonataAdminBundle/issues/2857","id":64643404,"number":2857,"title":"Bad index on text collection type","user":{"login":"Soullivaneuh","id":1698357,"avatar_url":"https://avatars.githubusercontent.com/u/1698357?v=3","gravatar_id":"","url":"https://api.github.com/users/Soullivaneuh","html_url":"https://github.com/Soullivaneuh","followers_url":"https://api.github.com/users/Soullivaneuh/followers","following_url":"https://api.github.com/users/Soullivaneuh/following{/other_user}","gists_url":"https://api.github.com/users/Soullivaneuh/gists{/gist_id}","starred_url":"https://api.github.com/users/Soullivaneuh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Soullivaneuh/subscriptions","organizations_url":"https://api.github.com/users/Soullivaneuh/orgs","repos_url":"https://api.github.com/users/Soullivaneuh/repos","events_url":"https://api.github.com/users/Soullivaneuh/events{/privacy}","received_events_url":"https://api.github.com/users/Soullivaneuh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-26T22:01:34Z","updated_at":"2015-03-26T22:01:34Z","closed_at":null,"body":"Giving the following Doctrine entity attribute:\r\n\r\n```php\r\n/**\r\n * @var string[]\r\n *\r\n * @ORM\\Column(type=\"array\", name=\"press_images_blacklist\", nullable=true)\r\n */\r\nprivate $pressImagesBlacklist;\r\n```\r\n\r\nAnd the following admin form mapping of this attribute:\r\n\r\n```php\r\n$formMapper\r\n    ->add('pressImagesBlacklist', 'collection', [\r\n        'type'          => 'text',\r\n        'allow_add'     => true,\r\n        'allow_delete'  => true,\r\n    ])\r\n;\r\n```\r\n\r\n**Step 1:** load an entity for edition with the some strings already on array (toto, tata, titi), you will get this:\r\n\r\n![sonata_collection_step_1](https://cloud.githubusercontent.com/assets/1698357/6857984/0fc78a92-d40b-11e4-897a-5de30a646f90.png)\r\n\r\nWith the following rendered text `input` tag:\r\n\r\n```html\r\n<!-- [...] -->\r\n<input type=\"text\" id=\"s55147f49f21b1_pressImagesBlacklist_1\" name=\"s55147f49f21b1[pressImagesBlacklist][1]\" required=\"required\" class=\" form-control\" value=\"toto\">\r\n<!-- [...] -->\r\n<input type=\"text\" id=\"s55147f49f21b1_pressImagesBlacklist_2\" name=\"s55147f49f21b1[pressImagesBlacklist][2]\" required=\"required\" class=\" form-control\" value=\"tata\">\r\n<!-- [...] -->\r\n<input type=\"text\" id=\"s55147f49f21b1_pressImagesBlacklist_3\" name=\"s55147f49f21b1[pressImagesBlacklist][3]\" required=\"required\" class=\" form-control\" value=\"titi\">\r\n<!-- [...] -->\r\n```\r\n\r\n**Step 2:** Add a field by clicking on `+` icon and fill it with whatever. You will get this:\r\n\r\n![sonata_collection_step_2](https://cloud.githubusercontent.com/assets/1698357/6858002/5a8681dc-d40b-11e4-9dbc-f856d319a701.png)\r\n\r\nWith the following new `input` tag:\r\n\r\n```html\r\n<input type=\"text\" id=\"s55147f49f21b1_pressImagesBlacklist_1\" name=\"s55147f49f21b1[pressImagesBlacklist][1]\" required=\"required\" class=\" form-control\">\r\n```\r\n\r\nActually you should already see the problem... ;)\r\n\r\n**Step 3:** Submit your wonderful form and you will get... this:\r\n\r\n![sonata_collection_step_3_result](https://cloud.githubusercontent.com/assets/1698357/6858029/8f2ad38e-d40b-11e4-9835-7f4f295385b0.png)\r\n\r\nInteresting isn't it? Very annoying too. :)\r\n\r\nThe problem is when you want to add a input from an existing list, sonata doesn't care of that and start with a new index, beginning by `1`. Obviously, if you submit that, the first element is overridden by the new element instead of being just added.\r\n\r\nMy current symfony and sonata installation:\r\n\r\n```\r\nsymfony/symfony                          2.7.x-dev 350f30b  The Symfony PHP framework\r\nsonata-project/admin-bundle              dev-master 8594eb4 Symfony SonataAdminBundle\r\nsonata-project/block-bundle              2.3.0              Symfony SonataBlockBundle\r\nsonata-project/cache                     1.0.4              Cache library\r\nsonata-project/core-bundle               2.3.1              Symfony SonataCoreBundle\r\nsonata-project/doctrine-orm-admin-bundle 2.3.1              Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle\r\nsonata-project/easy-extends-bundle       2.1.9              Symfony SonataEasyExtendsBundle\r\nsonata-project/exporter                  1.3.4              Lightweight Exporter library\r\nsonata-project/intl-bundle               2.2.1              Symfony SonataIntlBundle\r\n```\r\n\r\nI'm working on a fix right now. I will submit a PR if I find out and fix the issue.\r\n\r\nThanks."}}