Good afternoon,
I am using the wizard component with a partial view on step 1, and a form on step 2.
@(Html.Kendo().Wizard()
.Name("uploadWizard")
.Events(events => {
events.Select("onFormSelect");
events.FormValidateFailed("onFormValidateFailed");
})
.ValidateForms(v => v.ValidateOnPrevious(false))
.LoadOnDemand(true)
.ReloadOnSelect(false)
.Steps(s => {
s.Add()
.Title("Choose Route")
.ContentId("chooseRoute")
.Buttons(b =>
{
b.Next();
});
s.Add<TransactionViewModel>()
.Title("File Details")
.Form(form =>
{
form.FormData(Model);
form.Items(items =>
{
items.Add()
.Field(f => f.FileVersion)
.Label(label => label.Text("Version of file (if applicable) e.g. 1.00:")
.Optional(true))
.InputHtmlAttributes(new { @maxlength = "50" });
items.Add()
.Field(f => f.FileDescription)
.Label(label => label.Text("Description of file use/content:"))
.Editor(e => e.TextArea()
.MaxLength(256)
.Rows(2)
);
items.Add()
.Field(f => f.BusinessReason)
.Label(label => label.Text("Business reason for the transfer:"))
.Editor(e => e.TextArea()
.MaxLength(256)
.Rows(2)
);
items.Add().Field(f => f.SourceUri).Label(label => label.Text("Source URI (if from an identifiable source):").Optional(true));
});
})
.Buttons(b =>
{
b.Previous();
b.Next();
});
s.Add().Title("Upload File").Content("Upload file");
})
)
The partial view content contains a Kendo dropdownlist and a Kendo grid. I need the user to have selected a value from the dropdownlist and the grid before the step 1 wizard button allows the navigation to step 2.
I have added required text inputs to the partial view to capture the required value of the dropdownlist and id of the selected row in the grid. I'm going to hide the inputs but I want the "this field is required" error messages to appear in a validation summary, as they do on the step 2 form.
I've tried adding @Html.ValidationSummary() to the partial view but the error messages still appear next to the text inputs (which are due to be hidden). The partial view isn't based on a model.
The wizard's select event checks if the two inputs are valid and prevents the user from moving on:
// Get the current step's container element
var container = e.sender.currentStep.element;
// Instantiate a validator for the container element
$(container).kendoValidator();
// Get the validator's reference
var validator = $(container).kendoValidator().data("kendoValidator");
// Validate a given input elements
if (!validator.validateInput($("#SourceEnvironmentId")) || !validator.validateInput($("#RouteId"))) {
// Prevent the wizard's navigation
e.preventDefault();
}
How do I get the validation error messages for the hidden inputs to appear in the validation summary on step 1?
Kind regards,
Richard