"Switch" function

Top  Previous  Next

"Switch" function allows you to output custom message depending on the user input. It simplifies some cases when you can use "If" condition. It should be used if you have radio buttons, dropdown menus, and multiple lists and on one hand want to leave field values short and simple, and on the other hand want to output human-readable text depending on user's choice.

Template:

{#sw(field_name, "field_values_separated_by_commas", "output_strings_separated_by_commas ")#}
 

Example:

Which way do you want to travel?

<label><input type="radio" name="travel" value="CAR">Drive a car</label>

<label><input type="radio" name="travel" value="HORSE" checked>Ride a horse</label>

<label><input type="radio" name="travel" value="PLANE">Take a plane</label>

We use "Switch" function in one of the templates or another form pages:

{#sw(travel, "CAR,HORSE,PLANE", "Drive a car,Ride a horse,Take a plane")#}

Let's say user check the "HORSE" radio button.

Result:

Ride a horse