{"action":"created","issue":{"url":"https://api.github.com/repos/FriendsOfSymfony/FOSRestBundle/issues/1018","repository_url":"https://api.github.com/repos/FriendsOfSymfony/FOSRestBundle","labels_url":"https://api.github.com/repos/FriendsOfSymfony/FOSRestBundle/issues/1018/labels{/name}","comments_url":"https://api.github.com/repos/FriendsOfSymfony/FOSRestBundle/issues/1018/comments","events_url":"https://api.github.com/repos/FriendsOfSymfony/FOSRestBundle/issues/1018/events","html_url":"https://github.com/FriendsOfSymfony/FOSRestBundle/issues/1018","id":68741762,"number":1018,"title":"Form validation does not show error messages","user":{"login":"marcoshoya","id":6484905,"avatar_url":"https://avatars.githubusercontent.com/u/6484905?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoshoya","html_url":"https://github.com/marcoshoya","followers_url":"https://api.github.com/users/marcoshoya/followers","following_url":"https://api.github.com/users/marcoshoya/following{/other_user}","gists_url":"https://api.github.com/users/marcoshoya/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoshoya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoshoya/subscriptions","organizations_url":"https://api.github.com/users/marcoshoya/orgs","repos_url":"https://api.github.com/users/marcoshoya/repos","events_url":"https://api.github.com/users/marcoshoya/events{/privacy}","received_events_url":"https://api.github.com/users/marcoshoya/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2015-04-15T17:32:49Z","updated_at":"2016-08-12T12:57:11Z","closed_at":"2015-04-15T18:28:47Z","body":"Hi guys,\r\n\r\nI'm trying submit a form to my controller but I can not get those errors messages from form.\r\n\r\nAccording to docs (http://symfony.com/doc/current/bundles/FOSRestBundle/2-the-view-layer.html#forms-and-views), I should get \r\n\r\n```\r\n{\r\n  \"code\": 400,\r\n  \"message\": \"Validation Failed\";\r\n  \"errors\": {\r\n    \"children\": {\r\n      \"username\": {\r\n        \"errors\": [\r\n          \"This value should not be blank.\"\r\n        ]\r\n      }\r\n    }\r\n  }\r\n```\r\n\r\nHowever, my response is:\r\n\r\n```\r\n{\r\n  \"children\": {\r\n    \"username\": [],\r\n  }\r\n}\r\n```\r\n\r\nMy config.yml\r\n```\r\nfos_rest:\r\n    disable_csrf_role: IS_AUTHENTICATED_ANONYMOUSLY\r\n    param_fetcher_listener: true\r\n    # formato default caso não seja informado\r\n    routing_loader:\r\n        default_format: json\r\n    view:\r\n        # registra os mimi types permitidos no header da request\r\n        mime_types: \r\n            json: ['application/json', 'application/json;version=1.0', 'application/json;version=1.1']\r\n        view_response_listener: 'force'\r\n        formats:\r\n            xml:  true\r\n            json: true\r\n        templating_formats:\r\n            html: true\r\n    format_listener: true\r\n    exception:\r\n        codes:\r\n            'Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException': 404\r\n            'Doctrine\\ORM\\OptimisticLockException': HTTP_CONFLICT\r\n        messages:\r\n            'Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException': true\r\n    allowed_methods_listener: true\r\n    access_denied_listener:\r\n        json: true\r\n    body_listener: true\r\n```\r\n\r\nMy controller:\r\n```\r\n<?php\r\n\r\nnamespace AppBundle\\Controller;\r\n\r\nuse Nelmio\\ApiDocBundle\\Annotation\\ApiDoc;\r\nuse FOS\\RestBundle\\Controller\\FOSRestController;\r\nuse FOS\\RestBundle\\Controller\\Annotations as Rest;\r\nuse Symfony\\Component\\HttpFoundation\\Request;\r\nuse Symfony\\Component\\Validator\\Constraints as Assert;\r\n\r\nclass SecurityController extends FOSRestController\r\n{\r\n\r\n    /**\r\n     * Auth\r\n     *\r\n     * @ApiDoc(\r\n     *  resource=true,\r\n     *  description=\"Do the authentication\",\r\n     *  parameters={\r\n     *      {\"name\"=\"username\", \"dataType\"=\"string\", \"required\"=true, \"description\"=\"username from user\"}\r\n     *  },\r\n     *  statusCodes={\r\n     *      200=\"Returned when successful\"\r\n     *  }\r\n     * )\r\n     *\r\n     * @Rest\\Post()\r\n     * @Rest\\View()\r\n     */\r\n    public function authAction(Request $request)\r\n    {\r\n        $form = $this->createFormBuilder()\r\n                ->add('username', 'text', array('constraints' => new Assert\\NotBlank()))\r\n                ->getForm();\r\n        \r\n        $form->handleRequest($request);\r\n        if ($form->isValid()) {\r\n            // do something\r\n        }\r\n        \r\n        return $form;\r\n        \r\n    }\r\n\r\n}\r\n```\r\n\r\nWhat I am doing wrong??? \r\n\r\nThanks in advance"},"comment":{"url":"https://api.github.com/repos/FriendsOfSymfony/FOSRestBundle/issues/comments/239438924","html_url":"https://github.com/FriendsOfSymfony/FOSRestBundle/issues/1018#issuecomment-239438924","issue_url":"https://api.github.com/repos/FriendsOfSymfony/FOSRestBundle/issues/1018","id":239438924,"user":{"login":"manasbala","id":1825710,"avatar_url":"https://avatars.githubusercontent.com/u/1825710?v=3","gravatar_id":"","url":"https://api.github.com/users/manasbala","html_url":"https://github.com/manasbala","followers_url":"https://api.github.com/users/manasbala/followers","following_url":"https://api.github.com/users/manasbala/following{/other_user}","gists_url":"https://api.github.com/users/manasbala/gists{/gist_id}","starred_url":"https://api.github.com/users/manasbala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manasbala/subscriptions","organizations_url":"https://api.github.com/users/manasbala/orgs","repos_url":"https://api.github.com/users/manasbala/repos","events_url":"https://api.github.com/users/manasbala/events{/privacy}","received_events_url":"https://api.github.com/users/manasbala/received_events","type":"User","site_admin":false},"created_at":"2016-08-12T12:57:11Z","updated_at":"2016-08-12T12:57:11Z","body":"You should return \r\n\r\n`\r\n$view = $this->view($form->getErrors(true));\r\nreturn $this->handleView($view);\r\n`"}}
{"actor":{"display_login":"manasbala"}}