{"action":"created","issue":{"url":"https://api.github.com/repos/playframework/playframework/issues/5992","repository_url":"https://api.github.com/repos/playframework/playframework","labels_url":"https://api.github.com/repos/playframework/playframework/issues/5992/labels{/name}","comments_url":"https://api.github.com/repos/playframework/playframework/issues/5992/comments","events_url":"https://api.github.com/repos/playframework/playframework/issues/5992/events","html_url":"https://github.com/playframework/playframework/issues/5992","id":145647015,"number":5992,"title":"DI should work in Forms","user":{"login":"eximius313","id":5578017,"avatar_url":"https://avatars.githubusercontent.com/u/5578017?v=3","gravatar_id":"","url":"https://api.github.com/users/eximius313","html_url":"https://github.com/eximius313","followers_url":"https://api.github.com/users/eximius313/followers","following_url":"https://api.github.com/users/eximius313/following{/other_user}","gists_url":"https://api.github.com/users/eximius313/gists{/gist_id}","starred_url":"https://api.github.com/users/eximius313/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eximius313/subscriptions","organizations_url":"https://api.github.com/users/eximius313/orgs","repos_url":"https://api.github.com/users/eximius313/repos","events_url":"https://api.github.com/users/eximius313/events{/privacy}","received_events_url":"https://api.github.com/users/eximius313/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2016-04-04T10:42:23Z","updated_at":"2016-04-05T22:57:32Z","closed_at":null,"body":"### Play Version (2.5.x / etc)\r\n2.5.1\r\n\r\n### API (Scala / Java / Neither / Both)\r\nJava\r\n\r\n### Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)\r\nN/A\r\n\r\n### JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)\r\nN/A\r\n\r\n### Library Dependencies\r\nN/A\r\n\r\n### Expected Behavior\r\n1. form validation method need's to use database repository or other DI service\r\n2. Service is being injected into form using ```@Inject```\r\n\r\n### Actual Behavior\r\n1. Using ```@Inject``` on a field is ignored\r\n2. Using ```@Inject``` in constructor throws:```\r\n[CompletionException: java.lang.RuntimeException: Cannot instantiate class controllers.myController.forms.MyForm. It must have a default constructor]```\r\n3. Using ```Play.application().injector().instanceOf(MyService.class)``` is deprecated\r\n"},"comment":{"url":"https://api.github.com/repos/playframework/playframework/issues/comments/206025289","html_url":"https://github.com/playframework/playframework/issues/5992#issuecomment-206025289","issue_url":"https://api.github.com/repos/playframework/playframework/issues/5992","id":206025289,"user":{"login":"gmethvin","id":171663,"avatar_url":"https://avatars.githubusercontent.com/u/171663?v=3","gravatar_id":"","url":"https://api.github.com/users/gmethvin","html_url":"https://github.com/gmethvin","followers_url":"https://api.github.com/users/gmethvin/followers","following_url":"https://api.github.com/users/gmethvin/following{/other_user}","gists_url":"https://api.github.com/users/gmethvin/gists{/gist_id}","starred_url":"https://api.github.com/users/gmethvin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gmethvin/subscriptions","organizations_url":"https://api.github.com/users/gmethvin/orgs","repos_url":"https://api.github.com/users/gmethvin/repos","events_url":"https://api.github.com/users/gmethvin/events{/privacy}","received_events_url":"https://api.github.com/users/gmethvin/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T22:57:32Z","updated_at":"2016-04-05T22:57:32Z","body":"I'm not sure the implementation would be trivial, and work with every DI framework implementation, since those classes will have some components injected and some not. Most model classes people are using with forms aren't designed to be created with DI.\r\n\r\nA lot of the forms code hasn't been touched in a while, and don't think any of the Play core developers that familiar with it. Before we start making tons of changes I would prefer to fully evaluate the options. I would be happier with a more pure JSR-303 approach based on validators than the \"custom\" solution we have now."}}