diff --git a/src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs b/src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs
index 8a95194d17..dfc7f42b31 100644
--- a/src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs
+++ b/src/Microsoft.AspNetCore.Mvc.TagHelpers/InputTagHelper.cs
@@ -32,7 +32,7 @@ public class InputTagHelper : TagHelper
{ "Url", "url" },
{ "EmailAddress", "email" },
{ "Date", "date" },
- { "DateTime", "datetime" },
+ { "DateTime", "datetime-local" },
{ "DateTime-local", "datetime-local" },
{ "Time", "time" },
{ nameof(Byte), "number" },
diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/TemplateRenderer.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/TemplateRenderer.cs
index 9ab89c98d1..9d2ee0578a 100644
--- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/TemplateRenderer.cs
+++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/TemplateRenderer.cs
@@ -48,7 +48,7 @@ public class TemplateRenderer
{ "Text", DefaultEditorTemplates.StringTemplate },
{ "Url", DefaultEditorTemplates.UrlInputTemplate },
{ "Date", DefaultEditorTemplates.DateInputTemplate },
- { "DateTime", DefaultEditorTemplates.DateTimeInputTemplate },
+ { "DateTime", DefaultEditorTemplates.DateTimeLocalInputTemplate },
{ "DateTime-local", DefaultEditorTemplates.DateTimeLocalInputTemplate },
{ "Time", DefaultEditorTemplates.TimeInputTemplate },
{ typeof(byte).Name, DefaultEditorTemplates.NumberInputTemplate },
diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/HtmlHelperOptionsTest.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/HtmlHelperOptionsTest.cs
index 8354547edf..0f8cc97ea1 100644
--- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/HtmlHelperOptionsTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/HtmlHelperOptionsTest.cs
@@ -28,7 +28,7 @@ public async Task AppWideDefaultsInViewAndPartialView()
An error occurred.
-
+
MySummary
- A model error occurred.
@@ -36,7 +36,7 @@ public async Task AppWideDefaultsInViewAndPartialView()
An error occurred.
-
+
False";
@@ -59,7 +59,7 @@ public async Task OverrideAppWideDefaultsInViewAndPartialView()
An error occurred.
-
+
True
MySummary
@@ -68,7 +68,7 @@ public async Task OverrideAppWideDefaultsInViewAndPartialView()
An error occurred.
-
+
True";
diff --git a/test/Microsoft.AspNetCore.Mvc.TagHelpers.Test/InputTagHelperTest.cs b/test/Microsoft.AspNetCore.Mvc.TagHelpers.Test/InputTagHelperTest.cs
index e7718c5214..191fc2d914 100644
--- a/test/Microsoft.AspNetCore.Mvc.TagHelpers.Test/InputTagHelperTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.TagHelpers.Test/InputTagHelperTest.cs
@@ -248,7 +248,8 @@ public async Task ProcessAsync_GeneratesExpectedOutput(
}
[Theory]
- [InlineData(null, "datetime")]
+ [InlineData("datetime", "datetime")]
+ [InlineData(null, "datetime-local")]
[InlineData("hidden", "hidden")]
public void Process_GeneratesFormattedOutput(string specifiedType, string expectedType)
{
@@ -820,7 +821,7 @@ public static TheoryData
InputTypeData
{ "custom-datatype", null, "text" },
{ "Custom-Datatype", null, "text" },
{ "date", null, "date" }, // No date/time special cases since ModelType is string.
- { "datetime", null, "datetime" },
+ { "datetime", null, "datetime-local" },
{ "datetime-local", null, "datetime-local" },
{ "DATETIME-local", null, "datetime-local" },
{ "Decimal", "{0:0.00}", "text" },
@@ -921,20 +922,88 @@ public async Task ProcessAsync_CallsGenerateTextBox_AddsExpectedAttributes(
Assert.Equal(expectedTagName, output.TagName);
}
+ [Fact]
+ public async Task ProcessAsync_CallsGenerateTextBox_InputTypeDateTime_RendersAsDateTime()
+ {
+ // Arrange
+ var expectedAttributes = new TagHelperAttributeList
+ {
+ { "type", "datetime" }, // Calculated; not passed to HtmlGenerator.
+ };
+ var expectedTagName = "not-input";
+
+ var context = new TagHelperContext(
+ allAttributes: new TagHelperAttributeList()
+ {
+ {"type", "datetime" }
+ },
+ items: new Dictionary