Skip to content

Instantly share code, notes, and snippets.

@ChuckBryan
Created July 12, 2014 22:27
Show Gist options
  • Save ChuckBryan/8c1939f40809a2df304c to your computer and use it in GitHub Desktop.
Save ChuckBryan/8c1939f40809a2df304c to your computer and use it in GitHub Desktop.
@model dynamic
@foreach (ModelMetadata prop in ViewData.ModelMetadata.Properties
.Where(p => p.ShowForEdit))
{
if (prop.TemplateHint == "HiddenInput")
{
@Html.Hidden(prop.PropertyName)
}
else
{
if (prop.ModelType == typeof(bool))
{
<div class="form-group">
<div class="col-md-2"></div>
<div class="checkbox col-md-10">
@Html.Editor(prop.PropertyName)
</div>
</div>
}
else
{
<div class="form-group">
@Html.BootstrapLabel(prop.PropertyName)
<div class="col-md-10">
@Html.Editor(prop.PropertyName)
@Html.ValidationMessage(prop.PropertyName, new { @class = "text-danger" })
</div>
</div>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment