-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Moving the generated hidden tags for checkbox to the end of the form #3311
Conversation
|
||
namespace Microsoft.AspNet.Mvc.Razor.TagHelpers | ||
{ | ||
[EditorBrowsable(EditorBrowsableState.Never)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? For the EditorBrowsable
bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that it doesn't show up in intellisense.
⌚ |
@@ -42,6 +42,10 @@ public class MvcRazorHost : RazorEngineHost, IMvcRazorHost | |||
{ | |||
LookupText = "Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNet.Mvc.Razor" | |||
}, | |||
new AddTagHelperChunk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spoke to @Eilon - instead of doing this, move it to Microsoft.AspNet.Mvc.TagHelpers
. Users will import it via _ViewImports
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⌚ |
Updated. |
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Advanced)] | ||
[HtmlTargetElement("form")] | ||
public class HiddenFormTagHelper : TagHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to be more general w/ these descriptions and names. Check boxes are one use of the infrastructure this helper provides. Perhaps ... to generate deferred content before the </form> end tag.
and RenderBeforeFormEndTagTagHelper
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per our discussion yesterday, this shouldn't say anything at all about anything being deferred. It's really entirely just about rendering stuff before the end of the form.
⌚ |
/// <summary> | ||
/// <see cref="ITagHelper"/> implementation targeting all form elements to generate hidden tag for checkboxes. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Advanced)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EditorBrowsableState.Advanced
wont do anything. Is there a follow up bug to make Razor treat Advanced
like Never
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be Never.
Looking really nice! |
@@ -94,5 +94,5 @@ | |||
<option>1002</option> | |||
</select> | |||
</div> <input type="submit" /> | |||
</form></body> | |||
<input name="[0].Remote" type="hidden" value="false" /><input name="[1].Remote" type="hidden" value="false" /><input name="[2].Remote" type="hidden" value="false" /></form></body> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not important here but at some point we should probably change the rendering to output void input tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NTaylorMullen we test both with and without the slash. Are you suggesting we test only without?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nooo, testing isn't what I'm referring to. I'm saying that we should always generate without.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought we decided long ago not to mess w/ how the user wrote an element in the .cshtml
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't what the user wrote though. These are generated to pass data to the server on post.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you're talking specifically about revisiting our decision to write these additional <input/>
(or <input>
) elements identically to the check boxes. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'm curious what has changed since we made that decision but let's take this offline. Unrelated to @ajaybhargavb's work here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be generating <self-closing />
tags to be XHTML compliant, which some people care about. It's never wrong, is it?
b7c9d9e
to
6f5bdfe
Compare
@ajaybhargavb is this updated and ready for another review round? |
@dougbu yes. Forgot to mention. |
Updated. |
var formContext = ViewContext.FormContext; | ||
if (formContext.HasEndOfFormContent) | ||
{ | ||
foreach (var hiddenTag in formContext.EndOfFormContent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hiddenTag
-> content
with just a couple of teensy changes |
|
||
[Theory] | ||
[MemberData(nameof(RenderAtEndOfFormTagHelperData))] | ||
public async Task Process_AddsHiddenInputTag_FromFormData(List<TagBuilder> tagBuilderList, string expectedOutput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update test name to not say FormData
Looking great, after tiny comments. |
…form - #2994 - Affects both HtmlHelper and TagHelper scenarios - Checkboxes not enclosed in a form will generate inline hidden tags - Added necessary properties to FormContext - Added some functional and unit tests
6f5bdfe
to
d40e661
Compare
#2994
@dougbu @pranavkm