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:
|
Let's start with form design. It will have just 2 fields
This means that we will have 2 variants of the same form (or 2 forms you may say)
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
ID | NAME | IS_ACTIVE |
---|---|---|
1 | This one | true |
2 | Another | true |
3 | Some inactive | false |
4 | Quattro | true |
5 | Obsolete | false |
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)
Important! 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