Forum

Thread tagged as: Problem

Reuse Perch Region For Options In Contact Form

I have a perch area which allows the client to add multiple open day dates to a page, and want to be able to take this data and add it to a contact form to allow people to select the correct date.

Code is:

 <section class="main nine">
            <?php perch_content('Open Day Info')?>
            <h3>The London Programme</h3>
            <?php perch_content('London Info')?>
            <?php perch_content('London Dates')?>

            <a href="#" title="Click To Apply" class="btn">Register For Open Day</a>

            <form id="form" method="post" action="open-days.php">
                <fieldset>
                    <label for="name">Name:</label>
                    <input type="text" id="name" name="name" placeholder="Please Enter Your Name">
                </fieldset>
                <fieldset>
                    <label for="email">Email:</label>
                    <input type="email" id="email" name="email" placeholder="Please Enter Your Email Address">
                </fieldset>
                <fieldset>
                    <label for="address">Address:</label>
                    <textarea id="address" name="address" placeholder="Please Enter Your Full Address"></textarea>
                </fieldset>
                <fieldset>
                    <label for="date">Open Day Date</label>
                    <select>
                        <option><?php perch_content('London Dates')?></option>
                    </select>
                </fieldset>
                <fieldset>
                    <input type="submit" value="Submit" name="submit">
                </fieldset>
            </form>

You can view the development site here

Any ideas as at the moment it is working but all the dates are showing up in one <option> field and i want it to be multiple option fields

The perch region code is

<p><perch:content id="open-day-dates" type="text" label="Open Day Date" required="true" title="true" /></p>
Stuart Cookney

Stuart Cookney 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Use this in your page:

<select>
    <?php perch_content('London Dates')?>
</select>

and this in the template:

<option><perch:content id="open-day-dates" type="text" label="Open Day Date" required="true" title="true" /></option>

thanks, i am using the same data on the page twice - https://dev5.foamymedia.com/open-days - firstly to populate the info on the page next to the calendar icons, and then i want to reuse this info to populate the options in the form...

so using the suggested code sample would not work in both places...

Drew McLellan

Drew McLellan 2638 points
Perch Support

It doesn't need to work in both places - use a different template for each circumstance.

but then they have to type out the date twice, rather than using the date of the event to populate the space on the website and then auto populate the form..

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't understand why. Use the same data, but output it using different templates.

ah...... ok got ya!