Logics in Aliveforms
In a nutshell, logic units are way to make form smart.
Logic units add extra level of interactivity in your forms. With logics forms in Aliveforms perform extra actions based upon conditions. For example, you set a rating screen. you want that if visitor gives more than 3 stars, show a message saying thank you.
In Aliveforms, basic interactivity like conditional branching is baked-in in form editor by setting next and previous screens in different scenario But Aliveforms is the nuclear arsenal of form building. There are multiple tools to add interactivity in forms. Aliveforms has very robust and flexible logics system for that.
Ways to Add Logics in form
In Aliveforms, there are 2 ways to add logics.
- Using Logic Units
- Using Calculation Block
Add Logic Using Logic Units
Logics units or modules are reusable units. Logic units contains conditions those have actions or code.
Add Logic Using Calculation Blocks
In Aliveforms, screen titles can have calculation block [/ ... /]
. In addition to performing calculations, this block doubles up as executing JavaScript API of Aliveforms when screen in rendered.
Types of Logic Units
When you create a new logic unit, you can select between two types of logic units:
- Client Side Logic Units
- Server Side Logic Units
Client Side Logic Units
These logic units are processed on visitor's device. They are useful to change flow, defining variables, doing calculations etc.
Server Side Logic Units
These are processed on server. They are useful for response manipulation, redirecting after form submission etc.
Logic Execution
It is important to know how logic in executed. In Client Side logic units, logics are executed
- Before first screen is shown
- Next button is pressed.
- Back button is pressed.
- Submit Button is pressed.
Server side logic is executed on server and actions are executed on client device.
Special Functions in Client Side JS
In Aliveforms there are special functions. these functions enable creating Single-Condition-Logic.
-
If using JavaScript API, special if function
screen_index_input_change
is defined, then it's body is executed when screen input is changed by user. -
If using JavaScript API, special if function
screen_index_on_next_pre
is defined, then it's body is executed when next button is clicked. It is executed before validation. -
If using JavaScript API, special if function
screen_index_on_next
is defined, then it's body is executed when next button is clicked. It is executed after validation. -
If using JavaScript API, special if function
screen_index_on_back
is defined, then it's body is executed when back button is clicked. -
If using JavaScript API, special if function
screen_index_on_enter
is defined, then it's body is executed when screen is rendered.
Event Handling in JavaScrip API
In Aliveforms there are events triggered on several occasions. Handling these events enables creating Single-Condition-Logic.
Events and Event Handling in Aliveforms
-
screen_index_input_change
is dispatched when screen input is changed by user. -
screen_index_on_next_pre
is dispatched when next button is clicked. It is executed before validation. -
screen_index_on_next
is dispatched when next button is clicked. It is executed after validation. -
screen_index_on_back
is dispatched when back button is clicked. -
screen_index_on_enter
is dispatched when screen is rendered.