I am looking to create an editor template for Object.cshtml to change the behavior of the Html.EditorForModel() method. I can\'t find any example of this using Razor. I have see
I'm just going to do the Display template and leave the rest as an exercise for the reader:)
@if (Model == null) {
@ViewData.ModelMetadata.NullDisplayText
} else if (ViewData.TemplateInfo.TemplateDepth > 1) {
@ViewData.ModelMetadata.SimpleDisplayText
} else {
@foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForDisplay && !ViewData.TemplateInfo.Visited(pm))) {
if (prop.HideSurroundingHtml) {
@Html.Display(prop.PropertyName)
} else {
@prop.GetDisplayName()
@Html.Display(prop.PropertyName)
}
}
}