This project is read-only.

Trying to understand input validation

Topics: Core, Customizing Orchard, Troubleshooting
Aug 19, 2014 at 10:39 PM
Hi - this is actually a cross post from SO, but was hoping that it might be more visible here - and get to the right people :)

The basic question is: where does input validation happen when saving a Content Type - specifically the Content Part Settings.

I have been able to get my setting to save just fine, and for the most part everything is working. My only serious issue lies in how data validation is occurring.

What I am doing is creating a list of all the fields and parts within the Content Type (that contains this specific Content Part), and the information is contained within a ViewModel - each field is added to a new custom class which holds the FieldName, a bool if it isIncluded, a "type" string and the "ordinal" value, which is an int. When creating each item the field type (TextField, MediaLibraryPickerField, etc.) is sent and a List of KeyValuePairs is created to populat a select list for the "type" of that field/part.

Everything saves into my ViewModel as expected, and in the TypeEditorUpdate method of my EditorEvents class I am grabbing the information that I need and able to use the builder to save the settings for those items that are selected.

However, if I do not set a value for the "ordinal" in the UI, and then try and save, an error is returned stating that "The Ordinal field is required".

I need to find a way to "bypass" or somehow cancel this validation, but I cannot find where the check is happening.

To add to the frustration, I have found that any errors returned (i.e.: even if I send something to the AddModelError method of updater) seem to mess with loading of the viewmodel. The select boxes do not contain any information as they did before.

Also, I noticed that any added fields that have setting of their own are not available (for Fields that would normally have an arrow next to them to expand the field settings, there is no arrow)

Does anyone have any thoughts on what might be going on here?

Or can point me in the direction to track down where the validation is occurring?