{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/2369","labels_url":"https://api.github.com/repos/aspnet/Mvc/issues/2369/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Mvc/issues/2369/comments","events_url":"https://api.github.com/repos/aspnet/Mvc/issues/2369/events","html_url":"https://github.com/aspnet/Mvc/issues/2369","id":67991935,"number":2369,"title":"TagHelpers `<label>`: Should support nested `<input>` elements","user":{"login":"Bartmax","id":3386797,"avatar_url":"https://avatars.githubusercontent.com/u/3386797?v=3","gravatar_id":"","url":"https://api.github.com/users/Bartmax","html_url":"https://github.com/Bartmax","followers_url":"https://api.github.com/users/Bartmax/followers","following_url":"https://api.github.com/users/Bartmax/following{/other_user}","gists_url":"https://api.github.com/users/Bartmax/gists{/gist_id}","starred_url":"https://api.github.com/users/Bartmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bartmax/subscriptions","organizations_url":"https://api.github.com/users/Bartmax/orgs","repos_url":"https://api.github.com/users/Bartmax/repos","events_url":"https://api.github.com/users/Bartmax/events{/privacy}","received_events_url":"https://api.github.com/users/Bartmax/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/Mvc/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/aspnet/Mvc/labels/needs%20design","name":"needs design","color":"006b75"},{"url":"https://api.github.com/repos/aspnet/Mvc/labels/TagHelpers","name":"TagHelpers","color":"bfdadc"}],"state":"open","locked":false,"assignee":{"login":"DamianEdwards","id":249088,"avatar_url":"https://avatars.githubusercontent.com/u/249088?v=3","gravatar_id":"","url":"https://api.github.com/users/DamianEdwards","html_url":"https://github.com/DamianEdwards","followers_url":"https://api.github.com/users/DamianEdwards/followers","following_url":"https://api.github.com/users/DamianEdwards/following{/other_user}","gists_url":"https://api.github.com/users/DamianEdwards/gists{/gist_id}","starred_url":"https://api.github.com/users/DamianEdwards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DamianEdwards/subscriptions","organizations_url":"https://api.github.com/users/DamianEdwards/orgs","repos_url":"https://api.github.com/users/DamianEdwards/repos","events_url":"https://api.github.com/users/DamianEdwards/events{/privacy}","received_events_url":"https://api.github.com/users/DamianEdwards/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnet/Mvc/milestones/9","html_url":"https://github.com/aspnet/Mvc/milestones/Backlog","labels_url":"https://api.github.com/repos/aspnet/Mvc/milestones/9/labels","id":673495,"number":9,"title":"Backlog","description":"Items to be considered in future releases that are currently not assigned any specific milestone.","creator":{"login":"yishaigalatzer","id":1238711,"avatar_url":"https://avatars.githubusercontent.com/u/1238711?v=3","gravatar_id":"","url":"https://api.github.com/users/yishaigalatzer","html_url":"https://github.com/yishaigalatzer","followers_url":"https://api.github.com/users/yishaigalatzer/followers","following_url":"https://api.github.com/users/yishaigalatzer/following{/other_user}","gists_url":"https://api.github.com/users/yishaigalatzer/gists{/gist_id}","starred_url":"https://api.github.com/users/yishaigalatzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yishaigalatzer/subscriptions","organizations_url":"https://api.github.com/users/yishaigalatzer/orgs","repos_url":"https://api.github.com/users/yishaigalatzer/repos","events_url":"https://api.github.com/users/yishaigalatzer/events{/privacy}","received_events_url":"https://api.github.com/users/yishaigalatzer/received_events","type":"User","site_admin":false},"open_issues":129,"closed_issues":8,"state":"open","created_at":"2014-05-28T21:50:24Z","updated_at":"2015-08-19T17:00:47Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-04-13T02:49:25Z","updated_at":"2015-08-23T20:27:52Z","closed_at":null,"body":"as of tag helper label, when there is not content, the displayname is shown while if there's content the content is used.\r\n\r\nThis is good because we can use\r\n```\r\n<label asp-for=\"RememberMe\"></label>\r\n```\r\nand\r\n```\r\n<label asp-for=\"RememberMe\">I want to be kept logged in on every visit</label>\r\n```\r\n\r\nbut there is a 'case' when we may want both, having content and providing the displayname from metadata/modelstate like this\r\n\r\n```\r\n<label asp-for=\"RememberMe\">\r\n    <input asp-for=\"RememberMe\" />\r\n</label>\r\n```\r\n\r\nThis will display a checkbox with empty text inside.\r\nI can do\r\n\r\n```\r\n<label asp-for=\"RememberMe\">\r\n    <input asp-for=\"RememberMe\" />\r\n    @Html.NameFor(m => m.RememberMe)\r\n</label>\r\n```\r\nThis works but I need to use old HtmlHelpers to read from modelstate/metadata.\r\n\r\nAnother problem is that label should only have one input inside and checkbox taghelper adds two for the model binder to work. This has no visual problem but is not valid html.\r\n\r\nthe intended result html is:\r\n```\r\n\r\n<label for=\"RememberMe\">\r\n    <input id=\"RememberMe\" name=\"RememberMe\" type=\"checkbox\" value=\"true\">\r\n    RememberMe\r\n</label>\r\n<input name=\"RememberMe\" type=\"hidden\" value=\"false\">\r\n\r\n```\r\n\r\nIs this kind of support added to the label taghelper somehow? \r\nIs there a plan to support this scenario ? (I know in MVC5 this was not possible with HtmlHelpers, but since you added tag helpers, I was hoping we have some way to sort this out)\r\n\r\nNote that bootstrap uses this structure so checkbox is aligned well on the form http://getbootstrap.com/css/#forms-example\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/comments/133924156","html_url":"https://github.com/aspnet/Mvc/issues/2369#issuecomment-133924156","issue_url":"https://api.github.com/repos/aspnet/Mvc/issues/2369","id":133924156,"user":{"login":"peterblazejewicz","id":14539,"avatar_url":"https://avatars.githubusercontent.com/u/14539?v=3","gravatar_id":"","url":"https://api.github.com/users/peterblazejewicz","html_url":"https://github.com/peterblazejewicz","followers_url":"https://api.github.com/users/peterblazejewicz/followers","following_url":"https://api.github.com/users/peterblazejewicz/following{/other_user}","gists_url":"https://api.github.com/users/peterblazejewicz/gists{/gist_id}","starred_url":"https://api.github.com/users/peterblazejewicz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterblazejewicz/subscriptions","organizations_url":"https://api.github.com/users/peterblazejewicz/orgs","repos_url":"https://api.github.com/users/peterblazejewicz/repos","events_url":"https://api.github.com/users/peterblazejewicz/events{/privacy}","received_events_url":"https://api.github.com/users/peterblazejewicz/received_events","type":"User","site_admin":false},"created_at":"2015-08-23T20:27:52Z","updated_at":"2015-08-23T20:27:52Z","body":"+1\r\n\r\nJust a note:\r\n\r\n> Another problem is that label should only have one input inside and checkbox taghelper adds two for the model binder to work. This has no visual problem but is not valid html.\r\n\r\nI think this is incorrect. Any `input` with `hidden` type is not interactive element at all, so the markup:\r\n```html\r\n<label>\r\n <input type=\"checkbox\" name=\"RememberMe\" value=\"true\" checked>\r\n <input type=\"hidden\" name=\"RememberMe\" value=\"false\">\r\n Remember Me?\r\n</label>\r\n```\r\nwill perfectly pass W3C validator.\r\nmore:\r\nhttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/label\r\nhttps://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\r\nspecifically:\r\n> <input>, if the type attribute is not in the hidden state"}}