I am creating a custom bizform. I have it all working except for two issues I am having with trying to better control the output of the error messages when field validation errors occur. I do NOT need to know how to customize the individual messages themselves, that is simple enough. What I want is to customize the placement of them.
1) The overall message that is being displayed when the form fails some validation. I just want to totally hide this message.
2) The individual validation messages per field. I want to combine all of these messages inside one DIV that only appears on the form when an error occurred.
for item 1) I tried overriding the ValidationErrorMessage property in the custom bizform control and set it return empty string and also tried adding this to the SetupControl function:
viewBiz.ValidationErrorMessage = "";
but no matter what it still displays a general validation error message on the submission of a form missing fields.
for item 2) I first tried just doing this in CMSDesk with a custom form, which allows me to stick the validation labels all at the top of the page but they are each in their own SPAN that Kentico generates and I can't just wrap them in a DIV here because the error div will always appear. (so my red div with exclamation icon appears even when no validation error is present). I was playing with outputting some custom JS to hide the div maybe but that just seems like hack.
Then I tried overriding the bizForm onPreRender and attempted to access the viewBiz.BasicForm.FieldErrorLabels collection. The idea was to loop through them, and combine them all into one custom div that I could output when one or more of them had a value. Unfortunately, I can't figure out how to access these objects. Does anyone know what type this collection is? I have tried 20 different ways of loop through this, casting it to many different things and I can't get it to work. I consulted the API documentation and it literally has NO information on this:
Kentico CMS 7.0 API Reference
FieldErrorLabels Property
Namespaces ► CMS.FormControls ► BasicForm ► FieldErrorLabels
Copyright (c) 2012 Kentico Software
Assembly: CMS.FormControls (Module: CMS.FormControls) Version: 7.0.4639.32326
Really helpful stuff...
I was able to get this loop to work:
for (i = 0; i < viewBiz.BasicForm.FieldErrorLabels.Count; i++)
But I can't cast viewBiz.BasicForm.FieldErrorLabels\[i\] to anything that does not throw an error. I tried CMS.FormControls.FormErrorLabel, and CMS.ExtendedControls.LocalizedLabel, and some other things...
I found this documentation:
http://devnet.kentico.com/docs/devguide/index.html?api_bizforms_customization_possibilities.htm
it mentions hash tables
If you wish to set up special behavior in the form during the editing process, individual controls that make up the fields, labels and validation error messages in the form can be accessed through the hash tables provided by the BizForm.BasicForm.FieldControls, BizForm.BasicForm.FieldLabels and BizForm.BasicForm.FieldErrorLabels properties.
but I tried casting to several types of collections with no luck.
Anyone have any idea how to achieve these two things?
THANKS!
Matt