Child pages
  • How to configure ConfiForms fields with conditional validation rules

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt Include
Creating a simple form
Creating a simple form
nopaneltrue

 

This is how the form looks like:

Image Added

 

Complete solution in storage format

Expand
Code Block
<ac:structured-macro ac:macro-id="edbecdec-64c6-4b39-bbbf-23952a70ec23" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f</ac:parameter>
  <ac:rich-text-body>
    <p>
      <ac:structured-macro ac:macro-id="2ee38079-27b7-4edb-a7cc-6613c23af6f0" ac:name="confiform-field-definition"
                           ac:schema-version="1">
        <ac:parameter ac:name="fieldName">type</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Type</ac:parameter>
        <ac:parameter ac:name="values">false[numbers=Numbers only|letters=Letters only|]</ac:parameter>
        <ac:parameter ac:name="type">select</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="ef9eff1a-ce22-4678-a05f-b165027eb9a0" ac:name="confiform-field-definition"
                           ac:schema-version="1">
        <ac:parameter ac:name="fieldName">val</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Value</ac:parameter>
        <ac:parameter ac:name="type">text</ac:parameter>
      </ac:structured-macro>
      <ac:structured-macro ac:macro-id="760927dc-06e4-4027-8811-bb863630051a" ac:name="confiform-entry-register"
                           ac:schema-version="1">
        <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
        <ac:rich-text-body>
          <p>&nbsp;</p>
        </ac:rich-text-body>
      </ac:structured-macro>
      <ac:structured-macro ac:macro-id="254041c2-175f-4ee9-bc18-4ff62ca16ab6" ac:name="confiform-field-definition-rules"
                           ac:schema-version="1">
        <ac:parameter ac:name="condition">type:numbers</ac:parameter>
        <ac:parameter ac:name="fieldName">Please enter numeric value</ac:parameter>
        <ac:parameter ac:name="values">^[0-9,;]+$</ac:parameter>
        <ac:parameter ac:name="action">Validation rule</ac:parameter>
        <ac:parameter ac:name="actionFieldName">val</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="1ced7eda-f1e8-484b-af45-c15922005685" ac:name="confiform-field-definition-rules"
                           ac:schema-version="1">
        <ac:parameter ac:name="condition">type:letters</ac:parameter>
        <ac:parameter ac:name="fieldName">Only letters are allowed</ac:parameter>
        <ac:parameter ac:name="values">^[a-zA-Z]*$</ac:parameter>
        <ac:parameter ac:name="action">Validation rule</ac:parameter>
        <ac:parameter ac:name="actionFieldName">val</ac:parameter>
      </ac:structured-macro>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>

 

Pieces of a puzzle (how it looks like in the Confluence editor)

Image Added

We have simple form (ConfiForms Form), 2 fields (2 ConfiForms Field definitions), 1 ConfiForms Registration Control and 2 ConfiForms Field Definition Rules macros

Let's see in more details how the "type" field is configured:

Image Added

It is a dropdown field with 2 choices: numbers (Numbers only) and letters (Letters only)

Next important bit is 2 ConfiForms Field Definition Rules macros and their configurations. Both rules are set to track "val" field and executed based on a condition, meaning based on the selection made in the "type" field. See screenshots below

Image Added

Image Added

 

And here is how the form behaves when validation fails

Image Added

Image Added

 

When validation is successful the record is saved into the form storage, otherwise the appropriate error message is shown