This repository was archived by the owner on Jan 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
This repository was archived by the owner on Jan 11, 2018. It is now read-only.
data-val and data-val-required not always added #76
Copy link
Copy link
Open
Description
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)
<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>
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)
<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">
@using (var row = Html.Bootstrap().GridRow().Begin())
{
using (var g1 = row.GridColumn(6).Begin())
{
@f.SelectFor(x => x.Inventory.EntryTypeID).AddOption(null).AddOptions(Model.EntryTypeDropdown).SetControlLabel(null).SetSize(InputSize.Sm).AddAttribute("data-role", "selectize").AddAttribute("placeholder", "Item Status")
@f.SelectFor(x => x.Inventory.DeviceTypeID).AddOption(null).AddOptions(Model.DeviceTypeDropdown).SetControlLabel(null).SetSize(InputSize.Sm).AddAttribute("data-role", "selectize").AddAttribute("placeholder", "Device Type")
@f.InputFor(x => x.Inventory.AssetTag).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Asset Tag").AddCss("text-uppercase").AddAttribute("maxlength", "7").AddAttribute("data-input-mask", "assettag").SetReadonly(Model.IsEditable)
@f.InputFor(x => x.Inventory.Make).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Make").AddCss("text-uppercase").SetReadonly(Model.IsEditable)
@f.InputFor(x => x.Inventory.Model).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Model").AddCss("text-uppercase").SetReadonly(Model.IsEditable)
@f.InputFor(x => x.Inventory.SerialNumber).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Serial Number").AddCss("text-uppercase").SetReadonly(Model.IsEditable)
@f.TextAreaFor(x => x.Inventory.Comments).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Comments")
}
using (var g1 = row.GridColumn(6).Begin())
{
@f.InputFor(x => x.Inventory.DeviceName).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Device Name").AddCss("text-uppercase")
@f.SelectFor(x => x.Inventory.CenterID).AddOption(null).AddOptions(Model.CenterTypeDropdown).SetControlLabel(null).SetSize(InputSize.Sm).AddAttribute("data-role", "selectize").AddAttribute("placeholder", "Center")
@f.SelectFor(x => x.Inventory.DepartmentID).AddOption(null).AddOptions(Model.DepartmentTypeDropdown).SetControlLabel(null).SetSize(InputSize.Sm).AddAttribute("data-role", "selectize").AddAttribute("placeholder", "Department")
@f.InputFor(x => x.Inventory.Location).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Location")
@f.InputFor(x => x.Inventory.StaticIP).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Static IP").AddAttribute("data-input-mask", "ip")
@f.InputFor(x => x.Inventory.Username).SetControlLabel(null).SetSize(InputSize.Sm).SetPlaceholder("Username")
}
}`
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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels