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

Pulldown Menu

Pulldown menus (select input fields) allow the user to select an option from a pulldown list. It needs an opening and closing select tag, and an option tag for each option. Here's a simple example:

[form]
[select color]
[option '' 'Choose a Color']
[option 'red' Red]
[option 'blue' Blue]
[select][submit]
[form]


Here the field is color. Checking either color will return that value. The first option, if selected when the form is submitted, will submit a null value. To make this field required, set required=true in the opening select tag.

You can control which option is checked initially by setting a default value. If not set, the first option comes up (as in the example above). Notice the following:

[form]
[select color default=blue required=true]
[option '' 'Choose a Color']
[option 'red' Red]
[option 'blue' Blue]
[select][submit]
[form]


If you want retrieve a saved value to create a more dynamic effect, set the default parameter to some data or info var, and if a corresponding match is found, that option will come up selected.

Templates

The "default" parameter may not work if you use it in a search template. Consider the following example:

[select color default=blue]
[(search group=colors template='[option {+p2} {+title}]')]
[select]

This script retrieves a list of colors from a page group and nicely generates the options for a pull down menu. But, the search function is called before the select tag and processes all the option inputs. This makes it impossible for the default parameter to be applied to the option tags, and flag one as selected.

If you use fmt instead of template, this will solve the problem, but now your title variable does not get processed. That could be replaced with <(source {+p}:title)>. Another option is to put a conditional in the template instead, like this: [option {+p2} [if equal {+p2} blue]selected=true[if] {+title}].

Additional Parameters

There are no useful BoltWire parameters for this input type, as the value is preset by the form creator.

The required parameter conflicts with the HTML5 parameter, which is allowed. That is, if you set required=true, HTML5 browsers will block form submission--before BoltWire has a chance to. Older browsers will not recognize the parameter and ignore it, allowing BoltWire's check to kick in. If you want to rely fully on BoltWire so all users have the same experience, you can reset the HTML parameters allowed in config.php to not include "required". You can see the default value in variables.php.

By default the following html parameters are allowed:

name, value, size, class, id, style, disabled

To override the default message created when a form fails some input check, set msg to the value you wish, or set it to false to turn it off.

For information about how to insert javascript into a form element, please see that tutorial.