Forum

Thread tagged as: Question

How to populate a select box in a form with the values from a repeater region?

OK, so I have a list and detail page. Within the detail page template, I have a repeater region for adding thumnails with titles (colours). I also want on the detail page a form with a select box which is automatically populated with the colour titles from the repeater region. How do I go about this?

Can it be done in the detail template file or must it be done on the product page itself within the 'detail mode' section? The form comes at the end of the product detail region anyway so it could be done like this.

The repeater is as such:

<perch:repeater id="images" label="Available Colours" required="true"> <li><img src="<perch:content id="imagethumb" type="image" label="Thumbnail Image" width="50" height="50" />" alt="" width="50" height="50" order="2" /><br /> <perch:content id="colourname" type="text" label="Name" required="true" order="1" /></li> </perch:repeater>

Lisa Morena

Lisa Morena 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Should be something like:

<perch:input id="whatever" type="select" options="<perch:repeater id="images"><perch:content id="colourname" type="text"  /><perch:if not-exists="perch_item_last">, </perch:if></perch:repeater>" />

Ooh, thanks...and that should work even though it's not a perch form?

Answer is no, but of course, you made me realise that the answer is pretty obvious! Serves me right for working late! Thanks as always.

Drew McLellan

Drew McLellan 2638 points
Perch Support

No problem.