Conference Registration Form
Prerequisites: Getting the Project Files
Before you begin, this tutorial requires you to download two key assets from our GitHub repository:
- The "Form Template" Rule Project: The foundational project for creating dynamic forms.
- The Front-End Renderer: The HTML and JavaScript files needed to display the forms.
Follow these two steps to get everything you need.
Step 1: Import the Rule Projects into Studio
We use a PowerShell script to automatically find and install all the sample rule projects, including the essential "Form Template," into your Corticon.js Studio.
-
Navigate to the
sample-projects
Directory: -
Download the Import Script:
- In the file list, find and click on
Import-CorticonSamples.ps1
. - On the script's page, click the Download raw file button (the icon with a downward arrow).
- Save the script to a convenient location, like your Desktop.
- In the file list, find and click on
-
Run the Script:
- Open a PowerShell window, navigate to where you saved the file, and run it:
.\Import-CorticonSamples.ps1
- This script will temporarily clone the
dynamic-forms
repository in the background, find all the samples, and install them into your Corticon.js Studio.
- Open a PowerShell window, navigate to where you saved the file, and run it:
-
Restart Corticon.js Studio:
- After the script finishes, restart the studio. Go to Help -> Samples to find the "Form Template" project.
Step 2: Get the Front-End Files
The front-end rendering application is in the front-end-files
directory. We will use the downgit
tool to download just this specific folder.
-
Download the Directory:
- Click this direct link to download the
front-end-files
directory as a ZIP file: - Download
front-end-files
using downgit - This will download a file named
front-end-files.zip
.
- Click this direct link to download the
-
Unzip the Files:
- Create a main project folder on your computer for this work (e.g.,
C:\corticon-tutorial
). - Unzip the
front-end-files.zip
directly into that folder. Your folder structure should now look like this:C:\corticon-tutorial\
└── front-end-files\
├── clientSideComponent\
├── decisionServices\
├── trace\
└── index.html
└── ... (and other files)
- Create a main project folder on your computer for this work (e.g.,
-
Important Note for Later:
- As you proceed through the tutorials, you will generate new Decision Services from Corticon.js Studio. You must save these into the
decisionServices
subfolder. For example:C:\corticon-tutorial\front-end-files\decisionServices\
. This ensures the front-end application can find and load them.
- As you proceed through the tutorials, you will generate new Decision Services from Corticon.js Studio. You must save these into the
Tutorial: Building the Conference Form
Welcome to your first hands-on tutorial for building a dynamic form! In this guide, you will build a multi-stage conference registration form from scratch using the Form Template you just imported.
What You Will Learn:
- How to create a data model (Vocabulary) to store user information.
- How to build a form stage-by-stage using Rulesheets.
- How to ask the user questions using different UI controls like dropdowns, text fields, and checkboxes.
- How to create conditional logic, showing different questions based on the user's previous answers.
Let's get started!
Step 1: Building the Vocabulary
First, we need to define the data model for our form. This is where we tell Corticon what information we plan to collect.
-
In Corticon.js Studio, open the Form Template project you imported earlier.
-
In the Project Explorer, open the
Rule Vocabulary.ecore
file. -
You will see the standard
UI
,Container
,UIControl
, andOption
entities. We need to add one more to store our registrant's information. -
Expand the 'Data' folder in the rule vocabulary. Double click on the entity 'renameToYourPathToData', and enter
Registrant
. -
Right click on the entity called 'Data' and click 'Add Association'.
-
For the source entity name, keep 'Data.Data' for the the target entity name, select 'Data.Registrant', and click the 'One' button beneath it. Then, change 'Navigability' to 'Data.Data->Data.Registrant'.
-
Now, add attributes to the
Registrant
entity. Right-click theRegistrant
entity, select Add New Attribute, and create the following attributes one by one:
Attribute Name | Data Type |
---|---|
reg_level | String |
first | String |
last | String |
email | String |
subscribed | Boolean |
has_dietary_restrictions | Boolean |
lactose | Boolean |
Vegetarian | Boolean |
Vegan | Boolean |
peanut | Boolean |
Diabetic | Boolean |
Kosher | Boolean |
Halal | Boolean |
requires_lodging | Boolean |
requires_parking | Boolean |
low_floor | Boolean |
awayElevator | Boolean |
nonSmoke | Boolean |
plateNo | String |
track | String |
- When you are finished, your
Registrant
entity should look like this. Save your vocabulary file.
Step 2: Creating the Form Stages
Now we will create the rules for each stage of the form.
Stage 0: Registration Level
This is the first screen the user sees. We will ask them to choose a registration package.
- Right-click your project and select New > Rulesheet. Name it
Stage0.ers
. - In the Preconditions section, set the filter to
UI.currentStageNumber = 0
. This ensures these rules only run for the very first stage. - In the Actions section, add the following rules:
* Rule 1 (Set Data Path): Set
UI.pathToData
to the string'registrant'
. This tells the form to store all collected data in ourRegistrant
entity. * Rule 2 (Create Container): SetUI.containers
to aContainer.new
with atitle
of'Register'
. * Rule 3 (Create Dropdown): Add aUIControl.new
toUI.containers.uiControls
. Set itstype
to'MultipleChoices'
,fieldName
to'reg_level'
, andlabel
to'Which package would you like to register for?'
. * Rule 4, 5, 6 (Add Options): Add threeOption.new
toUI.containers.uiControls.option
to create the choices: 'Early Bird ($599)', 'Standard ($899)', and 'VIP ($1,199)'. * Rule 7 (Set Next Stage): SetUI.nextStageNumber
to1
.
Stage 1: Registrant Info
Here, we collect the user's name and email.
- Create a new Rulesheet named
Stage1.ers
. - Set the Precondition to
UI.currentStageNumber = 1
. - Add the following rules in the Actions section:
* Rule 1 (Create Container): Create a new
Container
with thetitle
'Registrant Info'. * Rule 2, 3, 4 (Add Text Inputs): Create threeUIControl.new
oftype
'Text'. Set theirfieldName
attributes tofirst
,last
, andemail
respectively, and give them appropriate labels. * Rule 5 (Add Checkbox): Create aUIControl.new
oftype
'SingleChoice' with thefieldName
subscribed
and the label 'Keep me up to date...'. * Rule 6 (Set Next Stage): SetUI.nextStageNumber
to2
.
Stage 2 & 3: Conditional Dietary Questions
This is a two-part stage. First, we ask a Yes/No question. Then, based on the answer, we either show more questions or skip ahead.
-
Create
Stage2.ers
with preconditionUI.currentStageNumber = 2
. * This rulesheet will create aMultipleChoices
control asking "Do you have any dietary restrictions?". ThefieldName
should behas_dietary_restrictions
. * Add twoOption
entities for 'Yes' and 'No' with values oftrue
andfalse
. * SetUI.nextStageNumber
to3
. -
Create
Stage3_Routing.ers
with preconditionUI.currentStageNumber = 3
. This is a special non-visual stage. * SetUI.noUiToRenderContinue
totrue
. * Create a Conditional Rule: * Condition:Registrant.has_dietary_restrictions = true
* Action:UI.nextStageNumber
=4
* Create a second Conditional Rule: * Condition:Registrant.has_dietary_restrictions = false
* Action:UI.nextStageNumber
=5
Stage 4: List Dietary Restrictions
This stage only shows if the user answered "Yes" in stage 2.
- Create
Stage4.ers
with preconditionUI.currentStageNumber = 4
. - Create a container titled 'Meal Reqs.'.
- Create multiple
SingleChoice
(checkbox) controls for each dietary need (lactose
,Vegan
,peanut
, etc.). - Set
UI.nextStageNumber
to5
.
...and so on for the remaining stages, following the logic in the ruleflow report to create rulesheets for lodging questions (Stages 5, 6, 7) and the final conference track selection (Stage 8). In the final stage, you will set UI.done
to true
.
Step 3: Assembling the Ruleflow
For this project, the stage progression is handled by rules, not by connecting rulesheets.
- Create a New > Ruleflow named
FormFlow.erf
. - Drag all of your rulesheets onto the canvas.
- Do not connect them. The
currentStageNumber
precondition on each sheet ensures they fire at the correct time.
Step 4: Testing Your Logic
Use the Ruletester in Studio to check your work.
- Open the Ruletester view.
- Test Case 1 (Initial Load):
* Input: Create a
UI
object withcurrentStageNumber = 0
. * Expected Output: TheUI
object should now havenextStageNumber = 1
and UI controls for the registration level dropdown. - Test Case 2 (Dietary Path):
* Input: Create a
UI
object withcurrentStageNumber = 3
and aRegistrant
object withhas_dietary_restrictions = true
. * Expected Output: TheUI
object should havenextStageNumber = 4
. - Test Case 3 (No Dietary Path):
* Input: Create a
UI
object withcurrentStageNumber = 3
and aRegistrant
object withhas_dietary_restrictions = false
. * Expected Output: TheUI
object should havenextStageNumber = 5
.
Conclusion
Congratulations! You have successfully built the logic for a complex, multi-stage dynamic form. You have learned how to model data, create UI controls with rules, and guide a user through a conditional path. The final step would be to compile this project into a Decision Service for the front-end team.