{"action":"opened","issue":{"url":"https://api.github.com/repos/dpaquette/TagHelperSamples/issues/44","repository_url":"https://api.github.com/repos/dpaquette/TagHelperSamples","labels_url":"https://api.github.com/repos/dpaquette/TagHelperSamples/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/dpaquette/TagHelperSamples/issues/44/comments","events_url":"https://api.github.com/repos/dpaquette/TagHelperSamples/issues/44/events","html_url":"https://github.com/dpaquette/TagHelperSamples/issues/44","id":183829698,"number":44,"title":"Form inside Modal ","user":{"login":"jedielson","id":12877446,"avatar_url":"https://avatars.githubusercontent.com/u/12877446?v=3","gravatar_id":"","url":"https://api.github.com/users/jedielson","html_url":"https://github.com/jedielson","followers_url":"https://api.github.com/users/jedielson/followers","following_url":"https://api.github.com/users/jedielson/following{/other_user}","gists_url":"https://api.github.com/users/jedielson/gists{/gist_id}","starred_url":"https://api.github.com/users/jedielson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jedielson/subscriptions","organizations_url":"https://api.github.com/users/jedielson/orgs","repos_url":"https://api.github.com/users/jedielson/repos","events_url":"https://api.github.com/users/jedielson/events{/privacy}","received_events_url":"https://api.github.com/users/jedielson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-18T23:32:10Z","updated_at":"2016-10-18T23:32:10Z","closed_at":null,"body":"How can we have an structure like this?\r\n\r\n```\r\n<modal title=\"Modal title\">\r\n    <form asp-controller=\"Controller\" asp-action=\"Action\" method=\"post\">\r\n        <modal-body>\r\n\r\n            <div class=\"form-horizontal\">\r\n                <div class=\"form-group\">\r\n                    <label asp-for=\"Nome\" class=\"control-label col-md-2\">Nome:</label>\r\n                    <div class=\"col-md-10\">\r\n                        <input asp-for=\"Nome\" type=\"text\" class=\"form-control\" />\r\n                    </div>\r\n                </div>\r\n            </div>\r\n\r\n        </modal-body>\r\n        <modal-footer>\r\n            <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>\r\n            <button type=\"button\" class=\"btn btn-primary\">Save changes</button>\r\n        </modal-footer>\r\n    </form>\r\n</modal>\r\n```\r\nThe modal was correctly generated, but the form was removed (as expected).\r\nI've tried to create another custom helper to form like\r\n\r\n```\r\n/// <summary>\r\n    /// A Bootstrap modal dialog\r\n    /// </summary>\r\n    [RestrictChildren(\"modal-body\", \"modal-footer\", \"form\")]\r\n    public class ModalTagHelper : TagHelper\r\n    {\r\n        /// <summary>\r\n        /// The title of the modal\r\n        /// </summary>\r\n        public string Title { get; set; }\r\n\r\n        /// <summary>\r\n        /// The Id of the modal\r\n        /// </summary>\r\n        public string Id { get; set; }\r\n\r\n        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)\r\n        {\r\n            var modalContext = new ModalContext();\r\n            context.Items.Add(typeof(ModalTagHelper), modalContext);\r\n\r\n            await output.GetChildContentAsync();\r\n\r\n            var template =\r\n$@\"<div class='modal-dialog' role='document'>\r\n    <div class='modal-content'>\r\n      <div class='modal-header'>\r\n        <button type = 'button' class='close' data-dismiss='modal' aria-label='Close' modal-close-action><span aria-hidden='true'>&times;</span></button>\r\n        <h4 class='modal-title' id='{context.UniqueId}Label'>{Title}</h4>\r\n      </div>\r\n        <div class='modal-body'>\";\r\n\r\n            output.TagName = \"div\";\r\n            output.Attributes.SetAttribute(\"role\", \"dialog\");\r\n            output.Attributes.SetAttribute(\"id\", Id);\r\n            output.Attributes.SetAttribute(\"aria-labelledby\", $\"{context.UniqueId}Label\");\r\n            output.Attributes.SetAttribute(\"tabindex\", \"-1\");\r\n            var classNames = \"modal fade\";\r\n            if (output.Attributes.ContainsName(\"class\"))\r\n            {\r\n                classNames = string.Format(\"{0} {1}\", output.Attributes[\"class\"].Value, classNames);\r\n            }\r\n            output.Attributes.SetAttribute(\"class\", classNames);\r\n            output.Content.AppendHtml(template);\r\n            if (modalContext.Body != null)\r\n            {\r\n                output.Content.AppendHtml(modalContext.Body);\r\n            }\r\n            output.Content.AppendHtml(\"</div>\");\r\n            if (modalContext.Footer != null)\r\n            {\r\n                output.Content.AppendHtml(\"<div class='modal-footer'>\");\r\n                output.Content.AppendHtml(modalContext.Footer);\r\n                output.Content.AppendHtml(\"</div>\");\r\n            }\r\n\r\n            output.Content.AppendHtml(\"</div></div>\");\r\n        }\r\n    }\r\n\r\n    /// <summary>\r\n    /// The modal-footer portion of Bootstrap modal dialog\r\n    /// </summary>\r\n    [HtmlTargetElement(\"modal-footer\", ParentTag = \"modal\")]\r\n    [HtmlTargetElement(\"modal-footer\", ParentTag = \"form\")]\r\n    public class ModalFooterTagHelper : TagHelper\r\n    {\r\n        /// <summary>\r\n        /// Whether or not to show a button to dismiss the dialog. \r\n        /// Default: <c>true</c>\r\n        /// </summary>\r\n        [HtmlAttributeName(\"show-dismiss\")]\r\n        public bool ShowDismiss { get; set; } = true;\r\n\r\n        /// <summary>\r\n        /// The text to show on the Dismiss button\r\n        /// Default: Cancel\r\n        /// </summary>\r\n        [HtmlAttributeName(\"dismiss-text\")]\r\n        public string DismissText { get; set; } = \"Cancel\";\r\n\r\n        /// <summary>\r\n        /// A classe CSS a ser aplicada no botão de dismiss.\r\n        /// Não é necessário aplicar btn\r\n        /// </summary>\r\n        [HtmlAttributeName(\"dismiss-css-class\")]\r\n        public string DismissCssClass { get; set; } = \"btn-default btn-100\";\r\n\r\n\r\n        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)\r\n        {\r\n            if (ShowDismiss)\r\n            {\r\n                output.PreContent.AppendFormat(@\"<button type='button' class='btn {0}' data-dismiss='modal' modal-close-action>{1}</button>\", DismissCssClass, DismissText);\r\n            }\r\n            var childContent = await output.GetChildContentAsync();\r\n            var footerContent = new DefaultTagHelperContent();\r\n            if (ShowDismiss)\r\n            {\r\n                footerContent.AppendFormat(@\"<button type='button' class='btn {0}' data-dismiss='modal' modal-close-action>{1}</button>\", DismissCssClass, DismissText);\r\n            }\r\n            footerContent.AppendHtml(childContent);\r\n            var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];\r\n            modalContext.Footer = footerContent;\r\n            output.SuppressOutput();\r\n        }\r\n    }\r\n\r\n    /// <summary>\r\n    /// The modal-body portion of a Bootstrap modal dialog\r\n    /// </summary>\r\n    [HtmlTargetElement(\"modal-body\", ParentTag = \"modal\")]\r\n    [HtmlTargetElement(\"modal-body\", ParentTag = \"form\")]\r\n    public class ModalBodyTagHelper : TagHelper\r\n    {\r\n        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)\r\n        {\r\n            var childContent = await output.GetChildContentAsync();\r\n            var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];\r\n            modalContext.Body = childContent;\r\n            output.SuppressOutput();\r\n        }\r\n    }\r\n```\r\nBut had no success...\r\n\r\nHow can I fix it?"}}
{"actor":{"display_login":"jedielson"}}