I have simple model class with DateTime property.
[Required]
[DataType(DataType.DateTime)]
public DateTime When { get; set; }
Currently Visual Studio Scaffolding generate this:
<div class="form-group">
@Html.LabelFor(model => model.When, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.When, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.When, "", new { @class = "text-danger" })
</div>
</div>
It's a simple text box. I want to override default scaffolding. I can add something to default templates and my changes are generated.
How to configure i.e. Create.cs.t4 file to generate bootstrap datetimepicker?
There is an if condition to check when this is a enum
else if (property.IsEnum && !property.IsEnumFlags)
or bool type
bool isCheckbox = property.TypeName.Equals(boolType);
My solution is to add if statement to check whether it's a datetime and generate my own input field. I checked web but it's not a common topic.