Design and CSS styles
Version 7.x > Design and CSS styles > Modifying form fields with FieldEditingControls View modes: 
User avatar
Member
Member
jeremiah.bayles-vinsolutions - 2/11/2013 2:55:34 PM
   
Modifying form fields with FieldEditingControls
I’m trying to add a honey pot field to our contact us form. When I add hidden field to the form via the Kentico GUI (with conditions making it invisible) it’s not available in the source so I don’t think it will actually work. However I also tried adding the form via the GUI and trying modify the style on prerender in my form control won’t work either (Code below). It is odd as it will actually let me change the value of the field in my form control but not the styling. Is this typical of Kentico and is there a solution to trying to implement a honeypot field? I had suggested we just add more validation methods to the form, but I was told that they want the same behavior as the existing forms.

Here is the method I’m using.
((CMS.FormControls.EditingFormControl)viewBiz.BasicForm.FieldEditingControls["Pooh"]).Style.Add("Visible", "False");

Thanks

User avatar
Member
Member
jeremiah.bayles-vinsolutions - 2/11/2013 2:58:19 PM
   
RE:Modifying form fields with FieldEditingControls
BTW, I have tried overriding and registering the OnLoad event and the OnPreRender Events too. The method will allow me to change/update the value, but not the style.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 2/11/2013 2:59:49 PM
   
RE:Modifying form fields with FieldEditingControls
HTML controls don't have a Visibile property so try setting it like this:
((CMS.FormControls.EditingFormControl)viewBiz.BasicForm.FieldEditingControls["Pooh"]).Style.Add("display", "none");

User avatar
Member
Member
jeremiah.bayles-vinsolutions - 2/11/2013 3:09:25 PM
   
RE:Modifying form fields with FieldEditingControls
That had no affect as well.

User avatar
Member
Member
jeremiah.bayles-vinsolutions - 2/11/2013 3:16:57 PM
   
RE:Modifying form fields with FieldEditingControls
Its strange. I thought it might be that the bizform object was out of scope when the override method had finished and it was rendered. But it lets me modify the other attributes. And I also wondered it was because the style sheet was overriding my applied style properties, but I don't see where that is happening....

Thanks for the quick reply though.

User avatar
Member
Member
jeremiah.bayles-vinsolutions - 2/11/2013 4:12:57 PM
   
RE:Modifying form fields with FieldEditingControls
Ok, I feel a bit like an idiot now... but under advanced settings there are separate style inputs for the caption and the input and I can just set the properties right there. I'm going to go a bit further and actually and add a form field control for the field type, but yeah. That is how it is done.