Skip to main content

Hi,

 

I'm fairly new to smartforms. 

 

I have a bunch of text boxes, checkboxes and radio button groups in my view and they are bound to SmartObject Fields . All these fields are required fields. When the Form or the View is opened, I wanted to indicate that these controls are required either with a red astrisk or a red border around the control. The fields are defined as required in the SmartObject. I'm not intested in using conditional styling as I have write rules in so many places (when Form is initialized then on each controls lose focus, finally on submit button to validate if the values is present or not,etc. ). 

 

I tried view passes validation rule when the view is initialized, this work only for text boxes. i.e. only text boxes are highlighted. The rest of the controls are not bordered red. Also if I add a value to the required text box(that is red bordered) and empty the text box again, the border goes away. So the validation only fires the first time.

 

Is there a easy way to do this ,just like checking a checkbox  on a control that says that the control is required and it would automatically mark the control accordingly no matter whatever edits I make.  

 

Thanks!

Hi,


 


In the case of making users aware that these fields are required, you could use a Label control with text indicating so.


 


With regards to the styling of controls using validation, instead of setting a validation rule when the form is loaded - you could set a validation rule that checks whether the control is empty or not, in the event of the control being changed a rule event 'when the control is changed' could also be incorporated.


 


Regards


Thanks Taariq for your response. However if I have to mark all the labels red then it beats the purpose. Rather I'd leave them all in regular black color as the user is still not going to know which one he needs pay attention or having validation error.

 

Also I have some fields that I wanted to make required based on value entered in another field. Lets say I have a checkbox and a text box controls. When I check the checkbox I wanted the red * or a border around the text box. Again it partially works if I use Form Passes validation also adding conditional styling for achiving such a same funcationality will cause a maintainence issue especially since there are lot of controls in the Form.


You said you did not want to use conditional styling because of the rules. Firstly conditional styling does not create a 'rule' in the sense that it does not show it in the rules configuration. If the field is going to be required at all time then you might as well create a conditional styling on the view so you wont have to do it on the forms you use the view in. What you can do it set the default styling of control to red borders and then set the custom styling as a normal border. Set the condition of the conditional styling as "If the control is not empty'. This would take care of the required and not required validation. The styling of the regex validation can also be controlled by changing the CSS styling int he CSS file. I cannot remember fully but if you open up the css for the theme that you frms are using and then search for a class with .invalid at the end there is a class that controls the sytling of all invalid input control. Invalid as in if its set as required or the regex for the validation is set.

 

Hope this helps. 


I just cant stop thinking how much easier life would be if K2 could develop the Designer software to simply have a checkbox on the control properties so you could incidate required or not in one click. KISS principle in motion.


Reply