Join Now

Click here to join our
growing community:

JOIN LOGIN



Docs

Welcome Tour
Handbook
      Markups
      Variables
      Conditions
      Functions
      Forms
      Commands
      Concepts
Extensions
Pro Modules
Developers



Copyright © 2020
Terms of Use
Privacy Policy
BoltWire

Handbook

Warn

The warn command is similar to the message command in that it sends a message to the messaging system. It is different in that it aborts processing of the form immediately.

Here's a simple example of how it works:

[form]
[submit]
[command warn 'Stay on this page']
[command nextpage some.page]
[form]

The user submits a button. BoltWire hits the warn command, the message is returned, and the form aborts. To view the messages, the [messages] markup must appear somewhere on the page.

If a null value is set for the warn command, it is ignored and the form continues

[form]
[submit]
[command warn]
[command nextpage some.page]
[form]

These two facts make it possible to do some interesting thngs. Consider the following example:

[form]
[radio color red] Red   [radio color blue] Blue
[submit]
[command if "equal {=color} red ? warn='Don't pick this one!'"]
[command warn]
[command nextpage some.page]
[form]

If the user chooses red, the form will abort and give the warning message. If not, warn is ignored, and the user continues on. You could very easily use this technique to restrict access to a page to those who know some access code:

[form]
Enter Access Code: [text secret] [submit]
[command if "! equal {=secret} test ? warn='Access denied'"]
[command warn]
[command nextpage some.page]
[form]

You can also use this technique for any kind of input filtering or form processing you desire.

Advanced Features

Like the msg command, warn taps into BoltWire's internal messaging system allowing you to do some interesting things. Consider this form:

[form]
[submit]
[command msg hello]
[command warn goodbye id=msg]
[form]

Without the id tag, you would see both messages: hello and goodbye in the message output. But by adding the id, I can overwrite the first message and only get one message output. If you want to overwrite all the messages of a certain type, you can set the id to that message type. If you want to clear all other messages, set the id to all.

Another option is to only capture the message command. Consider this example:

[form]
[submit]
[command msg hello]
[command warn 'goodbye']
[form]

[messages warn]

Here BoltWire only displays the warn message because that is the only one retreived, though they all exist in the message array. You could also give warn a unique command and then retrieve that id. I can use this technique to retrieve some messages in one location, and others in another--or limit certain messages to specific users.

For more information and examples about how messaging works in BoltWire, please see the msg command.

Error Pages

It is possible to have an aborted from go to an error page rather than simply aborting form processing and staying on the current page. To do this, just add a nextpage argument to the command:


This will abort the for if the condition is met, and redirect the user immediately to main.error. If there is a messages markup on that page, the error message will show up there.