Page tree
Skip to end of metadata
Go to start of metadata

This is the documentation for ConfiForms Server/Data Center app


With ConfiForms Field Definition Rules it is easy to configure your form to validate the fields to require values, conditionally.


You can easily set up the Field Definition to be required via macro parameters

But what if you need the field to have a value only when some other field is set?

Consider a simple form with just 2 fields: checkbox field and text field we want to make "required" when a checkbox field is checked

Confluence editor "view" of the form's configuration

Now we add a ConfiForms Field Definition rules macro and set it up to require a value for "myfield" when "makeRequired" field is checked

The condition here is set as follows

makeRequired:true AND myfield:[empty]

The remaining bits of the configuration for the Field Definition Rule are as follows

So, we set the validation rule to run when the condition is met and show the message we have configured


When we try to submit the form with empty value for the "myfield" when "makeRequired" field is checked we get the following response 


Complete storage format for the demo 

<ac:structured-macro ac:macro-id="564ab3d6-7c49-45c5-9e17-74c492fc1828" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">myform</ac:parameter>
  <ac:rich-text-body>
    <ac:structured-macro ac:macro-id="62cbf463-6860-4769-a16b-9dcc086910b3" ac:name="confiform-entry-register" ac:schema-version="1">
      <ac:parameter ac:name="embedded">true</ac:parameter>
      <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
      <ac:rich-text-body>
        <p>
          <br/>
        </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p>
      <ac:structured-macro ac:macro-id="8c774cc4-b415-47eb-bb28-8cd31891f4ba" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">makeRequired</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Make required</ac:parameter>
        <ac:parameter ac:name="type">checkbox</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="a1c484ce-abea-4ef8-a70f-41f718bd7337" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">myfield</ac:parameter>
        <ac:parameter ac:name="fieldLabel">myfield</ac:parameter>
        <ac:parameter ac:name="type">text</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <br/>
    </p>
    <ac:structured-macro ac:macro-id="c95709e3-984a-407f-b346-780d806f0542" ac:name="confiform-field-definition-rules" ac:schema-version="1">
      <ac:parameter ac:name="condition">makeRequired:true AND myfield:[empty]</ac:parameter>
      <ac:parameter ac:name="fieldName">myfield requires a value to be set when "makeRequired" field is checked</ac:parameter>
      <ac:parameter ac:name="action">Validation rule</ac:parameter>
    </ac:structured-macro>
    <p>
      <br/>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>