{"action":"closed","issue":{"url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/issues/290","labels_url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/issues/290/comments","events_url":"https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/issues/290/events","html_url":"https://github.com/doctrine/DoctrineMongoDBBundle/issues/290","id":63563783,"number":290,"title":"Document formtype throws TransformationFailedException","user":{"login":"integratedforpublishers","id":6708931,"avatar_url":"https://avatars.githubusercontent.com/u/6708931?v=3","gravatar_id":"","url":"https://api.github.com/users/integratedforpublishers","html_url":"https://github.com/integratedforpublishers","followers_url":"https://api.github.com/users/integratedforpublishers/followers","following_url":"https://api.github.com/users/integratedforpublishers/following{/other_user}","gists_url":"https://api.github.com/users/integratedforpublishers/gists{/gist_id}","starred_url":"https://api.github.com/users/integratedforpublishers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/integratedforpublishers/subscriptions","organizations_url":"https://api.github.com/users/integratedforpublishers/orgs","repos_url":"https://api.github.com/users/integratedforpublishers/repos","events_url":"https://api.github.com/users/integratedforpublishers/events{/privacy}","received_events_url":"https://api.github.com/users/integratedforpublishers/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-22T19:03:04Z","updated_at":"2015-03-29T19:51:38Z","closed_at":"2015-03-29T19:51:38Z","body":"When we use the \"document\" FormType a transformation error is thrown:\r\n\r\nUnable to reverse value for property path \"block\": The choice \"82d05e1e26fa38e3bf336f9ba68c5dc5\" does not exist or is not unique\r\n\r\nDocument/field defenition:\r\n```php\r\n    /**\r\n     * @var ContentBlock\r\n     * @ODM\\ReferenceOne(targetDocument=\"Integrated\\Bundle\\ContentBundle\\Document\\Block\\ContentBlock\")\r\n     * @Type\\Field(\r\n     *      type=\"document\",\r\n     *      options={\r\n     *          \"class\"=\"IntegratedContentBundle:Block\\ContentBlock\",\r\n     *          \"property\"=\"title\",\r\n     *          \"placeholder\"=\"\"\r\n     *      }\r\n     * )\r\n     */\r\n```\r\n\r\nQueries executed by Doctrine:\r\ndb.block.find({ \"_id\": \"82d05e1e26fa38e3bf336f9ba68c5dc5\", \"class\": { \"$in\": [ \"Integrated\\Bundle\\ContentBundle\\Document\\Block\\ContentBlock\" ] } }).limit(1).limit();\r\ndb.block.find({ \"_id\": [ \"82d05e1e26fa38e3bf336f9ba68c5dc5\" ], \"class\": { \"$in\": [ \"Integrated\\Bundle\\ContentBundle\\Document\\Block\\ContentBlock\" ] } });\r\n\r\nThe second query is wrong, because the _id is passed as array, so it doesn't give results.\r\n\r\nWorkaround to fix the problem is to add \"expanded\"=true to the field options. When we do this no query is executed at all to find the the chosen document.\r\n\r\nDoctrine versions:\r\ndoctrine/annotations                  v1.2.3                                   MIT\r\ndoctrine/cache                        v1.4.0                                   MIT\r\ndoctrine/collections                  v1.2                                     MIT\r\ndoctrine/common                       v2.4.2                                   MIT\r\ndoctrine/data-fixtures                v1.0.0                                   MIT\r\ndoctrine/dbal                         v2.5.1                                   MIT\r\ndoctrine/doctrine-bundle              v1.4.0                                   MIT\r\ndoctrine/doctrine-cache-bundle        v1.0.1                                   MIT\r\ndoctrine/inflector                    v1.0.1                                   MIT\r\ndoctrine/instantiator                 1.0.4                                    MIT\r\ndoctrine/lexer                        v1.0.1                                   MIT\r\ndoctrine/mongodb                      1.1.8                                    MIT\r\ndoctrine/mongodb-odm                  1.0.0-BETA12                             MIT\r\ndoctrine/mongodb-odm-bundle           v3.0.0-BETA6                             MIT\r\ndoctrine/orm                          v2.4.7                                   MIT\r\n"}}