diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/CachedDataAnnotationsModelMetadata.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/CachedDataAnnotationsModelMetadata.cs
index 78decd573f..c9622d8608 100644
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/CachedDataAnnotationsModelMetadata.cs
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/CachedDataAnnotationsModelMetadata.cs
@@ -81,19 +81,19 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Calculate based on presence of an
+ /// Calculate based on presence of a
/// and its value.
///
///
/// Calculated value.
- /// if an exists.
+ /// if a exists.
/// null otherwise.
///
protected override string ComputeDisplayFormatString()
{
return PrototypeCache.DisplayFormat != null
? PrototypeCache.DisplayFormat.DataFormatString
- : base.ComputeEditFormatString();
+ : base.ComputeDisplayFormatString();
}
protected override string ComputeDisplayName()
@@ -114,13 +114,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Calculate based on presence of an
+ /// Calculate based on presence of a
/// and its and
/// values.
///
///
/// Calculated value.
- /// if an exists and
+ /// if a exists and
/// its is true; null otherwise.
///
///
diff --git a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataTest.cs b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataTest.cs
index 31443607b0..d042fbdc0b 100644
--- a/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataTest.cs
+++ b/test/Microsoft.AspNet.Mvc.ModelBinding.Test/Metadata/CachedDataAnnotationsModelMetadataTest.cs
@@ -321,6 +321,44 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
Assert.Equal(expected, result);
}
+ [Fact]
+ private void EditFormatString_DoesNotAffectDisplayFormat()
+ {
+ // Arrange
+ var provider = new DataAnnotationsModelMetadataProvider();
+ var metadata = new CachedDataAnnotationsModelMetadata(
+ provider,
+ containerType: null,
+ modelType: typeof(object),
+ propertyName: null,
+ attributes: Enumerable.Empty());
+
+ // Act
+ metadata.EditFormatString = "custom format";
+
+ // Assert
+ Assert.Null(metadata.DisplayFormatString);
+ }
+
+ [Fact]
+ private void DisplayFormatString_DoesNotAffectEditFormat()
+ {
+ // Arrange
+ var provider = new DataAnnotationsModelMetadataProvider();
+ var metadata = new CachedDataAnnotationsModelMetadata(
+ provider,
+ containerType: null,
+ modelType: typeof(object),
+ propertyName: null,
+ attributes: Enumerable.Empty());
+
+ // Act
+ metadata.DisplayFormatString = "custom format";
+
+ // Assert
+ Assert.Null(metadata.EditFormatString);
+ }
+
private class DataTypeWithCustomDisplayFormat : DataTypeAttribute
{
public DataTypeWithCustomDisplayFormat() : base("Custom datatype")