{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/18935","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/18935/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/18935/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/18935/events","html_url":"https://github.com/symfony/symfony/pull/18935","id":157951372,"number":18935,"title":"[Form] Consider a violation even if the form is not submitted","user":{"login":"egeloen","id":737992,"avatar_url":"https://avatars.githubusercontent.com/u/737992?v=3","gravatar_id":"","url":"https://api.github.com/users/egeloen","html_url":"https://github.com/egeloen","followers_url":"https://api.github.com/users/egeloen/followers","following_url":"https://api.github.com/users/egeloen/following{/other_user}","gists_url":"https://api.github.com/users/egeloen/gists{/gist_id}","starred_url":"https://api.github.com/users/egeloen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egeloen/subscriptions","organizations_url":"https://api.github.com/users/egeloen/orgs","repos_url":"https://api.github.com/users/egeloen/repos","events_url":"https://api.github.com/users/egeloen/events{/privacy}","received_events_url":"https://api.github.com/users/egeloen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/symfony/symfony/labels/BC%20Break","name":"BC Break","color":"e10c02"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Form","name":"Form","color":"DDDDDD"},{"url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Needs%20Review","name":"Status: Needs Review","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":44,"created_at":"2016-06-01T16:30:22Z","updated_at":"2016-08-29T18:47:07Z","closed_at":"2016-06-21T20:19:32Z","pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/18935","html_url":"https://github.com/symfony/symfony/pull/18935","diff_url":"https://github.com/symfony/symfony/pull/18935.diff","patch_url":"https://github.com/symfony/symfony/pull/18935.patch"},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | 2.7\r\n| Bug fix?      | yes\r\n| New feature?  | no\r\n| BC breaks?    | yes (only for the behavior)\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | #11493\r\n| License       | MIT\r\n| Doc PR        | \r\n\r\nHey!\r\n\r\nI'm currently implementing an API using the form component in order to validate the payload sent (in conjonction with the FOSRestBundle). Unfortunatelly, we dig into an issue about the PATCH request which don't map some of our validation rules to the form. Basically, the violations are lost in the middle of the process.\r\n\r\n### Use case\r\n\r\nWe have an entity with the following fields \"type\", \"image\" & \"video\". The field \"type\"can be either \"default\", \"image\" or \"video\" and then accordingly we use the appropriate field (none for the \"default\" type, video for the \"video\" type and image for the \"image\" type. Then, in our form, we change the validation groups according to our entity type in order to make the \"image\" field mandatory if the type is \"image\" and the same for the video field if the type is \"video\".\r\n\r\n### Current behavior\r\n\r\nThe current behavior (since 2.5) seems to not propages a violation to a form if this form is not submitted but in our use case, changing the field \"type\" via a PATCH request triggers some new validation which should be reported to end user (inform that a field (video or image) is missing in the PATCH request).\r\n\r\n### Expected behavior\r\n\r\nThe current behavior was introduced in #10567 but IMO, this update is a bug as suggested by @webmozart in https://github.com/symfony/symfony/issues/11493#issuecomment-59549054 Instead, the form component should still map validation errors to the form even if the field was not submitted. If the initial data is not valid, then your initial data was buggy from the beginning but the form should not accept it and instead of silently ignoring the errors, end users should be informed and fix it.\r\n\r\nWDYT?"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/243217120","html_url":"https://github.com/symfony/symfony/pull/18935#issuecomment-243217120","issue_url":"https://api.github.com/repos/symfony/symfony/issues/18935","id":243217120,"user":{"login":"natebrunette","id":1831497,"avatar_url":"https://avatars.githubusercontent.com/u/1831497?v=3","gravatar_id":"","url":"https://api.github.com/users/natebrunette","html_url":"https://github.com/natebrunette","followers_url":"https://api.github.com/users/natebrunette/followers","following_url":"https://api.github.com/users/natebrunette/following{/other_user}","gists_url":"https://api.github.com/users/natebrunette/gists{/gist_id}","starred_url":"https://api.github.com/users/natebrunette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natebrunette/subscriptions","organizations_url":"https://api.github.com/users/natebrunette/orgs","repos_url":"https://api.github.com/users/natebrunette/repos","events_url":"https://api.github.com/users/natebrunette/events{/privacy}","received_events_url":"https://api.github.com/users/natebrunette/received_events","type":"User","site_admin":false},"created_at":"2016-08-29T18:47:07Z","updated_at":"2016-08-29T18:47:07Z","body":"@egeloen That could work with extremely thorough testing, however, handling each case individually seems very prone to error.  I would much prefer a standard way to inform symfony I would like the entire object validated."}}
{"actor":{"display_login":"natebrunette"}}