FormItStateOptions
Last updated Nov 27th, 2019 | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn moreWhat is FormItStateOptions?¶
FormItStateOptions is an assistance snippet for FormIt 1.7.0+ that will output an option list of U.S. states. It is useful for forms that need a dropdown list of U.S. states.
Usage¶
Simply add the Snippet to your form, in a <select>
call:
<select name="state">
[[!FormItStateOptions? &selected=`[[!+fi.state]]`]]
</select>
Note how we are passing the value of the "fi.state" placeholder (which stores the value of the state field) into the selected parameter. This tells FormItStateOptions to select the last-selected option in the form.
FormItStateOptions Properties¶
FormItStateOptions comes with some default properties you can override. They are:
Name | Description | Default |
---|---|---|
selected | The country value to select. | |
selectedAttribute | Optional. The HTML attribute to add to a selected country. | selected="selected" |
tpl | Optional. The chunk to use for each country dropdown option. | |
useAbbr | If 1, will use the state abbreviation for the value. If 0, will use the full state name. | 1 |
toPlaceholder | Optional. Use this to set the output to a placeholder instead of outputting directly. |
See Also¶
- FormIt.Hooks
- FormIt.Validators
- FormIt.FormItRetriever
- FormIt.Tutorials and Examples
- FormIt.FormItCountryOptions
- FormIt.FormItStateOptions
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn more