Page tree

Versions Compared

Key

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

With recent update to ConfiForms (from version 1.27+) you can enable the rules to filter out choices on smart and db fields (or even just simple dropdown fields) based on the values in another field (or fields)

This allows you to build forms with fields which are easier to fill in by your end users as the choices they have to make can be reduced automatically using the logic you set up

 

We have a form with 2 fields, one checkbox and another a field of type "dropdown" with a number of choices. See below

 

What we want to achieve is to show reduced amount of choices when "checkbox" field is checked (and when unchecked to show all the available choices)

Here is the form definition

Image Added

Dropdown choices

Image Added

 

We will show only choices 1 and 2 when checkbox field is checked

Will have a rule (actually 2 rules) to filter out when a checkbox field is checked and to show all choices when the field is unchecked 

Image Added

Added 2 Rules to the configuration with the following setup

 

First rules to filter out items in "choicesField"  (hooked up to "checkboxField" to fire on check/uncheck)

Image Added

Image Added

 

Second Rule is to show all the items in "choicesField" when checkbox field is unchecked

Image Added

Image Added

So, we apply a filter to show only items 1st and 2nd in the first rule

Code Block
choicesField:2 OR choicesField:1

And to show all the items when a checkbox is unchecked

Code Block
choicesField:*

 

Storage format for the solution

Code Block
<ac:structured-macro ac:macro-id="0a0bec89-c9f7-4392-beb0-5843444dd0c2" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">fform</ac:parameter>
  <ac:rich-text-body>
    <ac:structured-macro ac:macro-id="3b52f7ff-93dc-40e0-a6b5-0a3aec8229c6" ac:name="confiform-entry-register" ac:schema-version="1">
      <ac:rich-text-body>
        <p> </p>
      </ac:rich-text-body>
    </ac:structured-macro>
    <p>
      <ac:structured-macro ac:macro-id="0ecbdedc-23ec-4f9f-9e61-5dc397d96244" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">checkboxField</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Select to reduce the choices</ac:parameter>
        <ac:parameter ac:name="type">checkbox</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="f7f576f3-8c96-4bdc-9fd0-2dce6dca294f" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">choicesField</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Choices</ac:parameter>
        <ac:parameter ac:name="values">false[1=one and active|2=two and active|3=three and inactive|4=four and inactive|]</ac:parameter>
        <ac:parameter ac:name="type">select</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="e299f432-49d7-4799-98f1-b34c48d7dee7" ac:name="confiform-field-definition-rules" ac:schema-version="1">
        <ac:parameter ac:name="condition">checkboxField:true</ac:parameter>
        <ac:parameter ac:name="fieldName">choicesField</ac:parameter>
        <ac:parameter ac:name="values">choicesField:2 OR choicesField:1</ac:parameter>
        <ac:parameter ac:name="action">Apply Filter on a field</ac:parameter>
        <ac:parameter ac:name="actionFieldName">checkboxField</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="4e1c57e5-675f-4257-a572-c84704664764" ac:name="confiform-field-definition-rules" ac:schema-version="1">
        <ac:parameter ac:name="condition">checkboxField:false</ac:parameter>
        <ac:parameter ac:name="fieldName">choicesField</ac:parameter>
        <ac:parameter ac:name="values">choicesField:*</ac:parameter>
        <ac:parameter ac:name="action">Apply Filter on a field</ac:parameter>
        <ac:parameter ac:name="actionFieldName">checkboxField</ac:parameter>
      </ac:structured-macro>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>