Page tree

This is the documentation for ConfiForms Server/Data Center app

However, this might also work for ConfiForms cloud and in most cases it does. But please see this page to understand the differences between server and cloud versions of the ConfiForms app.

In this tutorial you will learn how to Use ConfiForms Field Definition Rule to reduce a number of choices in a dropdown field.

We will consider 2 setups - one which uses database and another, which uses other form.

This tutorial is aplicable not only to dropdown fields, but also to:

  • radio group fields
  • advanced dropdowns
  • multi-select fields
  • checkbox groups fields

If you are new to ConfiForms, please take a few minutes to read the Basic concepts Guide, or go through the video tutorial on that page.  (smile)


Let's start with form design. It will have just 2 fields

  • a checkbox field called "includeActiveOnly"
  • a dropdown field called "choices" with values loaded from
    • a database table
    • another form

This means that we will have 2 variants of the same form (or 2 forms you may say)


Dropdown choices from a database table

Let's start with the one which has a dropdown field with the values loaded from a database table

A table we connect as a dropdown source has the following structure

1This onetrue
3Some inactivefalse

This is stored in a table called "cf_demo_values"

create table cf_demo_values (id INTEGER NOT NULL, name CHARACTER(50) NOT NULL, is_active boolean);

Our "choices" dropdown is configured as follows

It uses the SQL to load the values

select id, name, is_active from cf_demo_values

Important note is that we actually load the values for all 3 columns, while only first 2 columns are used directly when showing the values in the dropdown.

However... we need these values from a 3rd column into our dataset to use then later in a filter (in ConfiForms Field Definition Rule)


When SQL is loaded into ConfiForms the names for columns which have underscore (_) in their names are removed

So, in our case the column "is_active" becomes "isactive"

This is very important when you use it in a filter later, see below

Then form in the view mode looks like this

And this is how it looks in the design mode

Let's see how the 2 last macros (Field Definition Rules) are configured

See an important bit on the filter field - we take only "active" rows. This "isactive" field value comes from an SQL, from a field "is_active"

This rule fires when checkbox is checked


Here is how the 2nd Rule is configured

In a filter we tell it to take ALL (this rule fires when checkbox is not checked)

Dropdown choices from another form

This is a 2 version of the form, when your dropdown field is actually takes the values from another ConfiForms Form (using a "smart" field, a "smart" dropdown)

In the edit mode the form looks exactly the same as in the 1st version.

But the difference is in how the "choices" field is configured

It is configured to take the vlues from another ConfiForms Form with the following structure

  • Field to store name (field types is "text")
  • Field to store the status (active or inactive), with field type "checkbox"

Same set of values as in the database version

And the "choices" field is configured like this:

Taking the values from a "choiceForm" and showing those in teh dropdown

As we have the same field name to show if the choice is active or not the Field Definition Rules stay the same as in the version 1 of the form.

Giving us the same result in the end

Showing only active choices and serving them from another ConfiForms Form


Complete solution for version 1 of the form

<ac:structured-macro ac:macro-id="29ea6581-a183-4fac-b595-8161170b3d06" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f</ac:parameter>
    <ac:structured-macro ac:macro-id="ec132d3d-37c5-48d8-8a11-afc352b2e01a" ac:name="confiform-entry-register" ac:schema-version="1">
        <p> </p>
      <ac:structured-macro ac:macro-id="a35a3f59-9af3-4b51-a083-e3666d6e033a" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">includeActiveOnly</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Only active</ac:parameter>
        <ac:parameter ac:name="type">checkbox</ac:parameter>
      <ac:structured-macro ac:macro-id="94905715-ee3a-440c-9556-86db790db4a9" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">choices</ac:parameter>
        <ac:parameter ac:name="fieldLabel">Your choice</ac:parameter>
        <ac:parameter ac:name="values">select id, name, is_active from cf_demo_values</ac:parameter>
        <ac:parameter ac:name="extras">7422036e-9a6f-4455-92d9-7140131fb9da</ac:parameter>
        <ac:parameter ac:name="type">dbselect</ac:parameter>
      <ac:structured-macro ac:macro-id="afcef165-b323-4b02-adb0-9cfd00d61da2" ac:name="confiform-field-definition-rules" ac:schema-version="1">
        <ac:parameter ac:name="condition">includeActiveOnly:true</ac:parameter>
        <ac:parameter ac:name="fieldName">choices</ac:parameter>
        <ac:parameter ac:name="values">isactive:true</ac:parameter>
        <ac:parameter ac:name="action">Apply Filter on a field</ac:parameter>
        <ac:parameter ac:name="actionFieldName">includeActiveOnly</ac:parameter>
      <ac:structured-macro ac:macro-id="310c818c-9460-4d7b-a780-ba66ba4c5dda" ac:name="confiform-field-definition-rules" ac:schema-version="1">
        <ac:parameter ac:name="condition">includeActiveOnly:false</ac:parameter>
        <ac:parameter ac:name="fieldName">choices</ac:parameter>
        <ac:parameter ac:name="values">*</ac:parameter>
        <ac:parameter ac:name="action">Apply Filter on a field</ac:parameter>
        <ac:parameter ac:name="actionFieldName">includeActiveOnly</ac:parameter>