Audience
  • Developers
  • Form Designers
Required Knowledge
  • Controls
  • Views
  • Forms
  • Rules

Introduction

The latest How To topics are available in the K2 Five User Guide or the K2 Cloud User Guide’s How to section.

The option to disable validation on hidden, disabled or read-only controls, Views and tabs is now available. The option is selected by default for all new controls, Views and tabs created that are hidden, disabled or read-only. Controls, Views and tabs that were hidden, disabled or set to read-only in versions prior to K2 smartforms 1.0.2, will be deselected and the option will have to be checked manually should the validation not be required on these.

Implementation Details

Controls, Views and tabs can be validated by using the if the form passes validation condition in the Rule Designer.

Image

 Clicking on configure next to the condition will open the validation screen. The check box under Options can be selected to disable the validation on hidden, disabled or read-only controls, Views and tabs. This will result in all other controls selected to be validated except the hidden, disabled and read-only controls, Views and tabs.

Image

Definitions: 

Required - Requires a value for the validation to succeed. A required control will automatically be validated against the data type of the control.
Validate - Validates the value of the control against the data type of the control, for example does a control of type Number contain a valid number.
Do not validate, hidden, disabled and read-only controls, Views or tabs - All controls belonging to these categories will be ignored when validation is performed, i.e. no validation will be performed.

When using a Form with Views, the controls on those can also be selected to be disabled for validation.

Image

Views and tabs can be configured to be hidden and disabled by using Actions in the Rule Designer or the Views can be hidden or disabled by changing the Properties of the View in the Form Designer.

 
Note: The Do not validate hidden, disabled or read-only controls, Views and tabs option will also be applied to controls and Views that are dynamically changed to disabled or read-only at runtime. For example, if a control is enabled and is subsequently changed in runtime to be disabled, this option will be applied to that control if the validation is done after the control is changed to disabled.

Example Scenario

In this scenario we will use a Form with Views and tabs, a certain View and tab will be hidden to demonstrate the option to not perform validation on controls, Views and tabs.

Follow the steps below to set up the scenario as described above:

  1. Create a SmartObject and generate an Item View, List View, Editable List View and Form from the SmartObject.
  2. Create another View that is not bound to a SmartObject containing different View controls.
  3. On the Form create a tab and drag the unbound View onto the canvas of the tab.
  4. Your Form should resemble the following:
    Image
  5. Select a View and deselect the Visible check box in the properties section
  6. Select another View and deselect the Enabled check box in the properties section.
  7. Rename the Views so you can identify which View is hidden and which View is disabled.
  8. Drag a Button control onto the Form and call it Validate.
  9. Go to the Rules and add the following Rule:
    Events: When a control on the Form raises an event
    Conditions: the Form passes validation
    Actions: Show a message
    Image
  10. Configure the message by clicking on configure next to the definition. Supply message details.
  11. Click on configure next to the if the form passes validation definition.
  12. Select the Validate check box for all the controls and ensure that the Do not validate hidden, disabled and read-only controls, Views or tabs check box is selected. Click OK. Finish the Rule.
    Image
  13. Drag another Button control onto the Form and call it Hide tab.
  14. Go to the Rules and add the following Rule:
    Events: When a control on the Form raises an event  
    Actions: Hide a tab
    Image
  15. Finish the Rule and the Form, and then Run the Form.
  16. Click the Validate button. Note the validation that is performed on the controls of both tabs.
    Image

    Image
     
  17. Supply valid values for all controls on both tabs and click Validate again. The message is displayed to say that Validation was successful. Click OK.
    Image
  18. Remove the values from all controls, and then click the Hide Controls tab button.
  19. Validation is now performed on the remaining tab.
    Image