Welcome Tour
Site Checklist
Our Story




This function allows you to tap into BoltWire's conditional engine and apply it to forms that are submitted in complex ways. It is a powerful command, but can be a bit tricky to get just right.

Basically the format looks like this:

[command if "equal {var1} {var2} ? field1=value1 , field2=value2 : field3=value3"]

The entire value must be enclosed in quotes.

It is divided into three sections:
1) The area before " ? " is the conditional. It can include any conditional BoltWire understands, and use boolean operators, negation, and parentheses to make complex expressions. This example is a simple equality test.

2) The area between " ? " and " : " are the affirmative actions--those performed if the conditional returns a value of true. Basically, the value of field1 is reset to value1, and field2 is reset to value2. You can include as many affirmative actions as desired, so long as they are separated by ' , '.

3) The area after the " : " are the negative actions--those performed if the conditional returns a value of false. In this case, field3 is reset to value3. You can add additional negative actions so long as they are separated by ' , '.

Here's an example to illustrate how this can be used:

Choose a color:
[radio color red] Red   [radio color blue] Blue
[command if "equal {=color} red ? warn='Don't pick this one!' :"]
[command warn]

Basically the user selects a radio box and submits the form. The first command checks to see if the selected color was red. If yes, the warn command is set to a specific message causing the form to abort and reload. If they pick blue, the nextpage value is set to the success page, and the warn command remains a null value (causing it to be ignored). The user is thus forwarded to the success page.

Other Methods

Unless your conditional needs to factor in user input, remember that you can use normal conditionals to modify your forms. Consider this example:

[if login][hidden greeting 'Welcome {id}'][else][hidden greeting 'Welcome visitor'][if]
[command passdata greeting]

This function checks to see if a user is logged in and sets the greeting to one of two options. When they submit the form, the page is refreshed and the greeting is passed to the form where it is picked up by the get variable just above the form and displayed. This method can be very useful in customizing forms.

Remember also that input fields and commands (except for search, info, and list) can take an if parameter directly. You can use this approach if you need to abort a form when a condition fails. For example, consider these lines:

[text check if='more {=check} 5']

This aborts if the user enters a value of 5 or less (the condition fails). Or here's a command:

[command edit {=content} if='equal {p}']

In this case the edit action only takes place if the user is editing

Note: Any custom conditionals you create are available wherever conditional are used including input filtering, and the if command.