You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
<inputdata-val="true" data-val-required="The Foo field is required." id="Foo" name="Foo" type="checkbox" value="true" /><inputname="Foo" type="hidden" value="false" /><labelfor="Foo">Foo?</label>
It is relatively common to style a label based on a checkboxes checked state e.g.
input[type="checkbox"] +label {
/* style a */
}
input[type="checkbox"]:checked+label {
/* style b */
}
The addition of the hidden input breaks this sort of selector.
I would suggest, putting the hidden input first (since it doesn't seem to matter which order the inputs are rendered in). So the above code would become:
<inputname="Foo" type="hidden" value="false" /><inputdata-val="true" data-val-required="The Foo field is required." id="Foo" name="Foo" type="checkbox" value="true" /><labelfor="Foo">Foo?</label>
The text was updated successfully, but these errors were encountered:
The Html.CheckBox HTML helpers and <input type="checkbox"> tag helper will render only the checkbox inline
These helpers will not render the hidden input, and instead add it to the current form's context
The form HTML helper will render all the extra hidden inputs at the bottom of the form
A new "hidden" <form> tag helper (editorbrowsable=never) will capture all <form> elements regardless of attributes and its sole job is to render the extra hidden inputs at the bottom of the form
If the HTML/tag helper cannot find a form context then it will fall back to the current behavior of rendering the hidden input immediately after the checkbox
…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
When rendering a checkbox input. There is a hidden input with a false value rendered after the checkbox input. See the example below.
becomes
It is relatively common to style a label based on a checkboxes checked state e.g.
The addition of the hidden input breaks this sort of selector.
I would suggest, putting the hidden input first (since it doesn't seem to matter which order the inputs are rendered in). So the above code would become:
The text was updated successfully, but these errors were encountered: