Here's another example based on what @George_Marinos mentioned:
{options=["option1", "option2", "option3"]}
{formmenu: name=menu; values={=options}}
What we're doing here is:
- creating a list called "options" - you can recognize that this is a list by the square brackets. Each option needs to be in quotation marks, otherwise it will be considered a variable name (more on that later)
- creating a formmenu command with the name "menu" and using the items in the list "options" as values in the formmenu command.
In other words, it's the same thing as doing this:
{formmenu: name=menu; option1; option2; option3}
There are different reasons why you would want to use one version over the other. If it's a relatively simple snippet, the second version will be perfectly fine. But if you're planning on regularly adding ites to the formmenu, you might want to go with the first version as it makes things easier to understand at a glance.
On a final note, I mentioned earlier how each item in a list needs to be surrounded by quotation marks, otherwise it will be interpreted as a variable name.
Here's what I mean. Try tilling in the three formtext fields and notice how it affects the formmenu command.
{formtext: name=option1}
{formtext: name=option2}
{formtext: name=option3}
{options=[option1, option2, option3]}
{formmenu: name=menu; values={=options}}
So now, "option1", "option2", "option3" are variables in the list. Each on is getting its contents from the respective formtext command.
Here's a practical example of how you might want to use this in a scenario where you have a number of set options, AND want an "other" customizable option. Let's also add a multiple
setting to make it possible to choose multiple options in the dropdown menu.
Other: {formtext: name=other}
{options=["This is the first option", "This is the second option", "This is the third option", other]}
{formmenu: name=menu; multiple=yes; values={=options}}