Forum
Populate dynamically a select form field
I am currently implementing a method to filter results on pages, and I am looking at this example from the docs https://solutions.grabaperch.com/architecture/user-filtered-lists.
It works nicely, but I am trying to pass a string to the "options" of the html "select" element in order to handle it dynamically, like so
PerchSystem::set_var('materials_list', $materials_list); // creating the string in php
<perch:input id="material" type="select" options=" <perch:content id="materials_list" /> " /> // inside the form template
I find that passing variables in the <perch:form> does not work as it does in regular <perch:content> templates.
I don't know why this is so and I am wondering if there is a solution to be able to populate the field options dynamically.
Which page function are you using to display the form?
I am using perch_form()
Then a
<perch:content />
tag won't be parsed.Try
<perch:forms />
instead.Sweet! Thank you