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.
We have 2 tables with dependent data
One-to-many from contractor_categories to contractor_subcategories
Dropdown fields use the following SQL queries
SELECT id, name FROM contractor_categories SELECT id, name, contractor_categories_id FROM contractor_subcategories
DB setup
create table contractor_categories (id int, name varchar(100)); create table contractor_subcategories (id int, name varchar(100), contractor_categories_id int); insert into contractor_categories values(1, 'Software Development'); insert into contractor_categories values(2, 'Cleaning'); insert into contractor_categories values(3, 'Security'); insert into contractor_subcategories values(4, 'General cleaning', 2); insert into contractor_subcategories values(5, 'Entrance', 3); insert into contractor_subcategories values(6, 'Night shifts only', 3); insert into contractor_subcategories values(7, 'Basement and perimeter', 3);
Form configuration
"Dependency" is defined using "ConfiForms Field Definition Rule" with action to filter choices
Rule is set to be connected to changes on "category" field (not shown on the screenshot, but it is the first parameter in the rules macro)
And important bit is the filter:
contractorcategoriesid:[entry.category.id]
Why "contractorcategoriesid" and not "contractor_categories_id" as in the SQL defined? Because the way the field name is defined, allowing no non-alphanumeric characters in it's name. SQL query results become the dataset similar to internal datasets stored within ConfiForms.
Storage format
<ac:structured-macro ac:macro-id="14859127-f36f-4e7f-9de8-219a6790b6e3" ac:name="confiform" ac:schema-version="1"> <ac:parameter ac:name="formName">f1</ac:parameter> <ac:rich-text-body> <ac:structured-macro ac:macro-id="fdff034e-b509-4a3f-ae55-ed872aa6d0be" 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="2da9717f-57f5-4eda-9670-57123708c625" ac:name="confiform-field-definition" ac:schema-version="1"> <ac:parameter ac:name="fieldName">category</ac:parameter> <ac:parameter ac:name="fieldLabel">Contractor Category</ac:parameter> <ac:parameter ac:name="values">SELECT id, name FROM contractor_categories</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> </p> <p> <ac:structured-macro ac:macro-id="415940f1-d144-445d-9b72-9821d0310930" ac:name="confiform-field-definition" ac:schema-version="1"> <ac:parameter ac:name="fieldName">subcategory</ac:parameter> <ac:parameter ac:name="fieldLabel">Contractor Sub Category</ac:parameter> <ac:parameter ac:name="values">SELECT id, name, contractor_categories_id FROM contractor_subcategories</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> </p> <p> <ac:structured-macro ac:macro-id="d6b863fc-69cb-45e3-bbeb-5c76578158f7" ac:name="confiform-field-definition-rules" ac:schema-version="1"> <ac:parameter ac:name="fieldName">subcategory</ac:parameter> <ac:parameter ac:name="values">contractorcategoriesid:[entry.category.id]</ac:parameter> <ac:parameter ac:name="action">Apply Filter on a field</ac:parameter> <ac:parameter ac:name="actionFieldName">category</ac:parameter> </ac:structured-macro> </p> </ac:rich-text-body> </ac:structured-macro>