(var f = Html.Bootstrap().Form("Upsert", "Inventory", FormMethod.Post).AddAttribute("autocomplete", "off").AddAttribute("data-result", "json-alert").Begin())
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="modalPopupLabel">Inventory Details</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
@Html.DropDownListFor(m => m.Inventory.EntryTypeID, Model.EntryTypeDropdown, "Select Entry Type", new { @class = "form-control select", data_role = "selectize", placeholder = "Item Status" })
</div>
<div class="form-group">
@Html.DropDownListFor(m => m.Inventory.DeviceTypeID, Model.DeviceTypeDropdown, "Select Device Type", new { @class = "form-control select", data_role = "selectize", placeholder = "Device Type" })
</div>
<div class="form-group">
@Html.TextBoxFor(m => m.Inventory.AssetTag, new { @class = "form-control text-uppercase", maxlength = "7", data_input_mask = "assettag", placeholder = "Asset Tag" }).ReadOnly(Model.IsEditable)
</div>
<div class="form-group">
@Html.TextBoxFor(m => m.Inventory.Make, new { @class = "form-control", placeholder = "Make" }).ReadOnly(Model.IsEditable)
</div>
<div class="form-group">
@Html.TextBoxFor(m => m.Inventory.Model, new { @class = "form-control text-uppercase", placeholder = "Model" }).ReadOnly(Model.IsEditable)
</div>
<div class="form-group">
@Html.TextBoxFor(m => m.Inventory.SerialNumber, new { @class = "form-control text-uppercase", placeholder = "Serial Number" }).ReadOnly(Model.IsEditable)
</div>
<div class="form-group">
@Html.TextAreaFor(m => m.Inventory.Comments, new { @class = "form-control", placeholder = "Comments" })
</div>
</div>
<div class="col-md-6">
<div class="form-group">
@Html.TextBoxFor(m => m.Inventory.DeviceName, new { @class = "form-control", placeholder = "Device Name" })
</div>
<div class="form-group">
@Html.DropDownListFor(m => m.Inventory.CenterID, Model.CenterTypeDropdown, "Select Center", new { @class = "form-control select", data_role = "selectize", placeholder = "Center" })
</div>
<div class="form-group">
@Html.DropDownListFor(m => m.Inventory.DepartmentID, Model.DepartmentTypeDropdown, "Select Department", new { @class = "form-control select", data_role = "selectize", placeholder = "Department" })
</div>
<div class="form-group">
@Html.TextBoxFor(m => m.Inventory.Location, new { @class = "form-control", placeholder = "Location" })
</div>
<div class="form-group">
@Html.TextBoxFor(m => m.Inventory.StaticIP, new { @class = "form-control", data_input_mask = "ip", placeholder = "Static IP" })
</div>
</div>
</div>
</div>
<div class="modal-footer">
<input type="submit" value="Save" class="btn btn-success" />
<button type="button" class="btn btn-info modal-remove" data-dismiss="modal">Close</button>
</div>
}
</div>
</div>
There seems to be an issue where validation isn't added. This is a partial view being dynamically added.
This view works, data-val and data-val-required are added correctly.
`
@using (var f = Html.Bootstrap().Form("Upsert", "Inventory", FormMethod.Post).AddAttribute("autocomplete", "off").AddAttribute("data-result", "json-alert").Begin())
{
@Html.AntiForgeryToken()
@f.HiddenFor(x => x.Inventory.ID)
Now when I attempt the following data-val and data-val-required are not added
`@using (var f = Html.Bootstrap().Form("Upsert", "Inventory", FormMethod.Post).AddAttribute("autocomplete", "off").AddAttribute("data-result", "json-alert").Begin())
{
@Html.AntiForgeryToken()
@f.HiddenFor(x => x.Inventory.ID)
Also another odd thing happening is when the validation issue is present, the lists are not selecting the value that is passed with the model.
Some sort of binding issue since both validation and select list selections aren't set properly?