Reputation: 1084
In Orchard 1.4.2, when fields like input field are marked as required, validation pop up appears. How is the validation happening without re-directing the user to another view?
To explain in details, If I have a form that I have attached to a page, the form field validation displays an error message ( may be it is through AJAX or javascript), but there is no re-direction to the 'form' view - it stays on that page view.
I need to add validation to another module without it re-directing to another view.
Any idea?
Upvotes: 1
Views: 1650
Reputation: 3110
You can find this bit of code in the InputFieldDriver class...
if (settings.Required && string.IsNullOrWhiteSpace(field.Value)) {
updater.AddModelError(GetPrefix(field, part), T("The field {0} is mandatory.", T(field.DisplayName)));
}
Adding a model error will send the user right back to the same page.
FYI, the fields module is a sub repository located here: https://orchardfields.codeplex.com/
The class I'm talking about is right here: https://orchardfields.codeplex.com/SourceControl/changeset/view/4d125be1a6b3#Drivers%2fInputFieldDriver.cs
Upvotes: 3