Populate Form Select Box with Events Title
Hey Guys
I am wanting to get pass my event title from an events template called event-data.html into my form template to use as select boxes. I can get a title to display on my page but I can't work out how to set the title as a variable to pass into the form template.
There might be a better way to do this...
Thanks
<?php
$opts = array(
'filter'=>'eventTitle',
'match'=>'eq',
'template'=>'events/listing/event-data.html',
'count'=> '1'
);
$eventData = perch_events_custom($opts);
perchSystem::set_var('event1', $eventData);
perch_content_custom('Form', array(
'template'=>'form.html'
));
?>
A filter doesn't do what you think it does. It filters the region by the given field. It doesn't reduce it to the given filed.
I think you want this;
Hi Drew
Thanks for the reply. Nothing is displaying with that code you gave me. Not sure why?
However I have got exactly what I want to pass to the form displaying on my page using the below code, my question is why can't I declare perch_events_custom as a variable? Currently it's just displaying the output above the form but will not pass into the form itself using perchSystem::set_vars
Thanks
What does the code I gave you output? You need to use
skip-template
as shown.It didn't output anything at all. What do I need to change?
Change:
to:
I'm still not getting anything to output at all. Any other ideas?
What's in your form template?
Which of those IDs comes from the event? I'd thought you wanted
eventTitle
but that's not in use in your template.Well I was trying to bring it in using <perch:content id="event1" /> which is just above the submit input. I just put it there to test getting the variable to come into the form.
You need to use the IDs from the event template.
Ok I've tried that and still nothing is outputting.
In the template:
On the page:
Ok I put up a <perch:showall /> and the event is showing up there. How do I get it to show within the form?
Thanks Drew. That's now working.
Is there an easy enough way that I can then populate the select boxes with multiple eventTitles? So a user can select one event out of all events?
Any thoughts on how I can get all of the Event Titles into my Select boxes?
It's a content region, not an events region at this point. Change:
to
I have the region showing now. What I want to know is how can I output multiple eventTitle's into my form select box?
Obviously there will be a clash of ID's in the form template. Can I set each individual eventTitle as a variable before it goes to the form template or is there a better way to achieve this? I know the client will only ever have a max of 15 events at one time.
You'll need to loop through the events and construct a comma-delimited options string to use for the select options
Ok thanks for that. Are there any previous posts or examples somewhere of how to go about that?
We don't have any previous examples - this isn't something anyone's asked before.