Last updated Oct 7th, 2020 | 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.
$292 per month—let's make that $500!Learn more
What 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.
Simply add the Snippet to your form, in a
<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 comes with some default properties you can override. They are:
|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.|
- FormIt.Tutorials and Examples