Forum

Thread tagged as: Question, Forms

Setting options in a Perch Forms template

Is there any way of defining the options in perch:input select field from outside the form? Feeding in a list of items from a perch:content region.

I've had a play with dataselect and variables but seems no dice.

Robert Sinclair

Robert Sinclair 4 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, the <perch:content /> tags get parsed before the <perch:input /> tags, so you can do something like

<perch:input type="select" options="<perch:content id="my_options" ...  />" ... />

Okay, thank you. That doesn't seem to work. If you use that it doesn't output anything.

However, if I change perch:content to perch:input it outputs a field with the variable content in it.

Drew McLellan

Drew McLellan 2638 points
Perch Support

How are you displaying the region? With perch_content_custom() ?

Curses! Thank you for that prompt. Yes, variables passed into a template only work only work for templates which are parsed at runtime. So perch_content_custom not perch_content.

I also tried to use the variable to set the name of the form so that I could set up a dynamic form that responded to different user options so that I would then direct submissions to different email addresses in admin. However, I get an error about calling a function on a non-object. Does the form submission check in with the original form and therefore doesn't like the renaming?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You cannot mess with the form ID. That must be a literal string.

Thank you for that clarification.