ModelMetadata: ShowForEdit property not appearing to work.
- by Dan
Iv wrote an MetaDataProvider like the one below and am using it in conjunction with Editor templates. The DisplayName is working correctly, but for some reason the ShowForEdit value it not having any effect. Any ideas?
public class MyModelMetadataProvider : DataAnnotationsModelMetadataProvider
{
protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType,
Func<object> modelAccessor, Type modelType, string propertyName)
{
var metadata = base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName); I
metadata.DisplayName = "test";
metadata.ShowForEdit = false;
metadata.ShowForDisplay = false;
metadata.HideSurroundingHtml = true;
return metadata;
}
}