Address TODO item in default `object` editor template
- add validation elements per property in this template - update editor template test to expect new `<span>` in result
This commit is contained in:
parent
796ff1d3d3
commit
53432e1483
|
|
@ -264,10 +264,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
|
|
||||||
builder.Append(templateBuilder.Build());
|
builder.Append(templateBuilder.Build());
|
||||||
|
|
||||||
// TODO: Add IHtmlHelper.ValidationMessage() and call just prior to closing the <div/> tag
|
|
||||||
if (!propertyMetadata.HideSurroundingHtml)
|
if (!propertyMetadata.HideSurroundingHtml)
|
||||||
{
|
{
|
||||||
builder.Append(" ");
|
builder.Append(" ");
|
||||||
|
builder.Append(html.ValidationMessage(
|
||||||
|
propertyMetadata.PropertyName,
|
||||||
|
message: null,
|
||||||
|
htmlAttributes: null,
|
||||||
|
tag: null));
|
||||||
|
|
||||||
builder.AppendLine(divTag.ToString(TagRenderMode.EndTag));
|
builder.AppendLine(divTag.ToString(TagRenderMode.EndTag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,14 @@ namespace Microsoft.AspNet.Mvc.Core
|
||||||
var expected =
|
var expected =
|
||||||
"<div class=\"editor-label\"><label for=\"Property1\">Property1</label></div>" + Environment.NewLine
|
"<div class=\"editor-label\"><label for=\"Property1\">Property1</label></div>" + Environment.NewLine
|
||||||
+ "<div class=\"editor-field\">Model = p1, ModelType = System.String, PropertyName = Property1," +
|
+ "<div class=\"editor-field\">Model = p1, ModelType = System.String, PropertyName = Property1," +
|
||||||
" SimpleDisplayText = p1 </div>" + Environment.NewLine
|
" SimpleDisplayText = p1 " +
|
||||||
|
"<span class=\"field-validation-valid\" data-valmsg-for=\"Property1\" data-valmsg-replace=\"true\">" +
|
||||||
|
"</span></div>" + Environment.NewLine
|
||||||
+ "<div class=\"editor-label\"><label for=\"Property2\">Property2</label></div>" + Environment.NewLine
|
+ "<div class=\"editor-label\"><label for=\"Property2\">Property2</label></div>" + Environment.NewLine
|
||||||
+ "<div class=\"editor-field\">Model = (null), ModelType = System.String, PropertyName = Property2," +
|
+ "<div class=\"editor-field\">Model = (null), ModelType = System.String, PropertyName = Property2," +
|
||||||
" SimpleDisplayText = (null) </div>" + Environment.NewLine;
|
" SimpleDisplayText = (null) " +
|
||||||
|
"<span class=\"field-validation-valid\" data-valmsg-for=\"Property2\" data-valmsg-replace=\"true\">" +
|
||||||
|
"</span></div>" + Environment.NewLine;
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
var model = new DefaultTemplatesUtilities.ObjectTemplateModel { Property1 = "p1", Property2 = null };
|
var model = new DefaultTemplatesUtilities.ObjectTemplateModel { Property1 = "p1", Property2 = null };
|
||||||
|
|
@ -85,11 +89,13 @@ namespace Microsoft.AspNet.Mvc.Core
|
||||||
var expected =
|
var expected =
|
||||||
@"<div class=""editor-label""><label for=""Property1"">Property1</label></div>" +
|
@"<div class=""editor-label""><label for=""Property1"">Property1</label></div>" +
|
||||||
Environment.NewLine +
|
Environment.NewLine +
|
||||||
@"<div class=""editor-field""><input class=""text-box single-line"" id=""Property1"" name=""Property1"" type=""text"" value="""" /> </div>" +
|
@"<div class=""editor-field""><input class=""text-box single-line"" id=""Property1"" name=""Property1"" type=""text"" value="""" /> " +
|
||||||
|
@"<span class=""field-validation-valid"" data-valmsg-for=""Property1"" data-valmsg-replace=""true""></span></div>" +
|
||||||
Environment.NewLine +
|
Environment.NewLine +
|
||||||
@"<div class=""editor-label""><label for=""Property3"">Property3</label></div>" +
|
@"<div class=""editor-label""><label for=""Property3"">Property3</label></div>" +
|
||||||
Environment.NewLine +
|
Environment.NewLine +
|
||||||
@"<div class=""editor-field""><input class=""text-box single-line"" id=""Property3"" name=""Property3"" type=""text"" value="""" /> </div>" +
|
@"<div class=""editor-field""><input class=""text-box single-line"" id=""Property3"" name=""Property3"" type=""text"" value="""" /> " +
|
||||||
|
@"<span class=""field-validation-valid"" data-valmsg-for=""Property3"" data-valmsg-replace=""true""></span></div>" +
|
||||||
Environment.NewLine;
|
Environment.NewLine;
|
||||||
|
|
||||||
var model = new DefaultTemplatesUtilities.ObjectWithScaffoldColumn();
|
var model = new DefaultTemplatesUtilities.ObjectWithScaffoldColumn();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue