Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Disable BizForm Field Validation in Custom code? View modes: 
User avatar
Certified Developer 11
Certified Developer 11
Cy - 1/11/2011 11:06:54 PM
   
Disable BizForm Field Validation in Custom code?
I was looking through the API at the BizForm docs and found that I should be able to get the BasicForm.FieldControls and FieldInfo() classes. I can see ways to set some of the validations rules programmatically. Is there a way to disable validation on specific fields on the fly.

We are trying to do conditional formatting where depending on whether the user selects an option in another field, we may have a handful of other fields to validate, if not, don't bother. We would like to keep the ability to manage the validation rules in the CMSDesk so adding a removing the rules at run time is not ideal.

Now that I'm thinking about it, we toggle the appropriate allowempty flag if we want to the field to be validated or not. Is there another way to disable validation at the field level?

User avatar
Certified Developer 11
Certified Developer 11
Cy - 1/11/2011 11:07:40 PM
   
RE:Disable BizForm Field Validation in Custom code?
I forgot to clarify, that we do know how to clone the bizform webpart and hook into the custom events.

User avatar
Certified Developer 11
Certified Developer 11
Cy - 1/12/2011 1:34:59 PM
   
RE:Disable BizForm Field Validation in Custom code?
After looping through the fieldcontrols collection on the bizform, we found that some of the fields (such as plain textboxes) can't be cast to the FormEngineUserControl or FormEngineWebControl so we cannot access the FieldInfo for that field to modify the validation rules, is there another way to do this?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 1/13/2011 6:17:24 AM
   
RE:Disable BizForm Field Validation in Custom code?
Hello,

I would recommend you the following approach:

1) Create two custom form controls, one for the dropdown and one for all the input fields (e.g. 3 times the First name, Last name email...etc). Those input fields will be named differently for each presenter, e.g (just an example).

<div id="P1">

FirstNameTextBox_1,
LastNameTextBox_1,

</div>

<div id="P2">

FirstNameTextBox_2,
LastNameTextBox_2,

</div>

<div id="P3">

FirstNameTextBox_3,
LastNameTextBox_3

</div>

Those sections will be encapsulated in three div containers with different ids , so you can dynamically hide/show themaccording to the dropdown selection.

2) In the dropdown custom form control you can set the selected number of presenters as a cookie/session/thread value.

3) You can get this value in the "public override bool IsValid()" method of the textbox cestom form control and validate the fields according to this (e.g. check if there is some text in FirstNameTextBox_2.Text if 2 presenters are selected )

4) The validation messasge can be set the following way:

this.ValidationError = "Please insert something in field First Name by presenter 2";

Best regards,
Boris Pocatko