From 53432e14836fd9b5cdeb475a05c96067ac040db0 Mon Sep 17 00:00:00 2001 From: dougbu Date: Mon, 11 Aug 2014 09:52:06 -0700 Subject: [PATCH] Address TODO item in default `object` editor template - add validation elements per property in this template - update editor template test to expect new `` in result --- .../Rendering/Html/DefaultEditorTemplates.cs | 7 ++++++- .../Rendering/DefaultEditorTemplatesTests.cs | 14 ++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs index 49d2bee693..7a62774805 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs @@ -264,10 +264,15 @@ namespace Microsoft.AspNet.Mvc.Rendering builder.Append(templateBuilder.Build()); - // TODO: Add IHtmlHelper.ValidationMessage() and call just prior to closing the
tag if (!propertyMetadata.HideSurroundingHtml) { builder.Append(" "); + builder.Append(html.ValidationMessage( + propertyMetadata.PropertyName, + message: null, + htmlAttributes: null, + tag: null)); + builder.AppendLine(divTag.ToString(TagRenderMode.EndTag)); } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultEditorTemplatesTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultEditorTemplatesTests.cs index 15ecc0060b..7996a4af89 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultEditorTemplatesTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultEditorTemplatesTests.cs @@ -19,10 +19,14 @@ namespace Microsoft.AspNet.Mvc.Core var expected = "
" + Environment.NewLine + "
Model = p1, ModelType = System.String, PropertyName = Property1," + - " SimpleDisplayText = p1
" + Environment.NewLine + " SimpleDisplayText = p1 " + + "" + + "
" + Environment.NewLine + "
" + Environment.NewLine + "
Model = (null), ModelType = System.String, PropertyName = Property2," + - " SimpleDisplayText = (null)
" + Environment.NewLine; + " SimpleDisplayText = (null) " + + "" + + "" + Environment.NewLine; // Arrange var model = new DefaultTemplatesUtilities.ObjectTemplateModel { Property1 = "p1", Property2 = null }; @@ -85,11 +89,13 @@ namespace Microsoft.AspNet.Mvc.Core var expected = @"
" + Environment.NewLine + -@"
" + +@"
" + +@"
" + Environment.NewLine + @"
" + Environment.NewLine + -@"
" + +@"
" + +@"
" + Environment.NewLine; var model = new DefaultTemplatesUtilities.ObjectWithScaffoldColumn();