{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/7737","labels_url":"https://api.github.com/repos/symfony/symfony/issues/7737/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/7737/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/7737/events","html_url":"https://github.com/symfony/symfony/issues/7737","id":13437738,"number":7737,"title":"[3.0] [Form] Inconsistency between isValid() and the \"valid\" template variable","user":{"login":"webmozart","id":176399,"avatar_url":"https://avatars.githubusercontent.com/u/176399?v=3","gravatar_id":"","url":"https://api.github.com/users/webmozart","html_url":"https://github.com/webmozart","followers_url":"https://api.github.com/users/webmozart/followers","following_url":"https://api.github.com/users/webmozart/following{/other_user}","gists_url":"https://api.github.com/users/webmozart/gists{/gist_id}","starred_url":"https://api.github.com/users/webmozart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webmozart/subscriptions","organizations_url":"https://api.github.com/users/webmozart/orgs","repos_url":"https://api.github.com/users/webmozart/repos","events_url":"https://api.github.com/users/webmozart/events{/privacy}","received_events_url":"https://api.github.com/users/webmozart/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/symfony/symfony/labels/Enhancement","name":"Enhancement","color":"02d7e1"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Form","name":"Form","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/symfony/symfony/milestones/10","html_url":"https://github.com/symfony/symfony/milestones/3.0","labels_url":"https://api.github.com/repos/symfony/symfony/milestones/10/labels","id":316623,"number":10,"title":"3.0","description":"","creator":{"login":"webmozart","id":176399,"avatar_url":"https://avatars.githubusercontent.com/u/176399?v=3","gravatar_id":"","url":"https://api.github.com/users/webmozart","html_url":"https://github.com/webmozart","followers_url":"https://api.github.com/users/webmozart/followers","following_url":"https://api.github.com/users/webmozart/following{/other_user}","gists_url":"https://api.github.com/users/webmozart/gists{/gist_id}","starred_url":"https://api.github.com/users/webmozart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webmozart/subscriptions","organizations_url":"https://api.github.com/users/webmozart/orgs","repos_url":"https://api.github.com/users/webmozart/repos","events_url":"https://api.github.com/users/webmozart/events{/privacy}","received_events_url":"https://api.github.com/users/webmozart/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":9,"state":"open","created_at":"2013-04-19T16:25:06Z","updated_at":"2015-04-11T22:34:57Z","due_on":null,"closed_at":null},"comments":18,"created_at":"2013-04-20T16:20:34Z","updated_at":"2015-05-13T02:46:55Z","closed_at":null,"body":"I'm calling out for you to decide how to resolve the inconsistency between the `Form::isValid()` method and the `valid` variable available in the template:\r\n\r\n* `isValid()` returns `false` if a form was not submitted. This way it is possible to write concise controller code:\r\n\r\n```php\r\n$form = $this->createForm(...);\r\n$form->handleRequest($request);\r\n\r\nif ($form->isValid()) {\r\n    // only executed if the form is submitted AND valid\r\n}\r\n```\r\n\r\n* `valid` contains `true` if a form was not submitted. This way it is possible to rely on this variable for error styling of a form.\r\n\r\n```\r\n<div{% if not form.vars.valid %} class=\"error\"{% endif %}>\r\n```\r\n\r\nWe have two alternatives for resolving this problem:\r\n\r\n1. Leave the inconsistency as is.\r\n2. Make `isValid()` return `true` if a form was not submitted (consistent with `valid`)\r\n3. Revert to the 2.2 behavior of throwing an exception if `isValid()` is called on a non-submitted form (not consistent with `valid`).\r\n\r\nBoth 2. and 3. will require additional code in the controller:\r\n\r\n```php\r\n$form = $this->createForm(...);\r\n$form->handleRequest($request);\r\n\r\nif ($form->isSubmitted() && $form->isValid()) {\r\n    // only executed if the form is submitted AND valid\r\n}\r\n```\r\n\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/101487513","html_url":"https://github.com/symfony/symfony/issues/7737#issuecomment-101487513","issue_url":"https://api.github.com/repos/symfony/symfony/issues/7737","id":101487513,"user":{"login":"JHGitty","id":5406438,"avatar_url":"https://avatars.githubusercontent.com/u/5406438?v=3","gravatar_id":"","url":"https://api.github.com/users/JHGitty","html_url":"https://github.com/JHGitty","followers_url":"https://api.github.com/users/JHGitty/followers","following_url":"https://api.github.com/users/JHGitty/following{/other_user}","gists_url":"https://api.github.com/users/JHGitty/gists{/gist_id}","starred_url":"https://api.github.com/users/JHGitty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JHGitty/subscriptions","organizations_url":"https://api.github.com/users/JHGitty/orgs","repos_url":"https://api.github.com/users/JHGitty/repos","events_url":"https://api.github.com/users/JHGitty/events{/privacy}","received_events_url":"https://api.github.com/users/JHGitty/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T02:46:55Z","updated_at":"2015-05-13T02:46:55Z","body":"What do you think now? Because it is referenced to 3.0 a BC break would be allowed."}}