Forum

Thread tagged as: Question, Forms

Forms App and hidden fields

Hi Drew/Rachel,

Is there any way to either:

a) Pass in the page title shown on the stored form response to the email response?

or

b) Pass in the page title using

<perch:pages id="pageNavText" />

somehow perhaps in combination with a hidden field

<perch:input type="hidden" id="centre" value="<perch:pages id="pageNavText" />" label="Centre" />

In short, my client needs to know which page the form was submitted from as we are using the same form, on different pages, created from a master.

Andy Knight

Andy Knight 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can do that. Pass it into the template: https://docs.grabaperch.com/docs/templates/passing-variables-into-templates/

Hi Drew,

Thanks for this. Im nearly there but just not sure how to get my data in to the variable.

On the page I have this code:

PerchSystem::set_var('lang', 'en');

In the form template I have this:

<perch:input type="hidden" label="Centre" id="lang" />

All works fine and 'en' is passed in to the email and form response in Perch.

My issue is replacing the 'en' with

<perch:pages id="pageNavText" />

I just get a blank or <perch:pages id="pageNavText" /> in the response.

I am clearly doing something wrong but I am not sure what!

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to use perch_pages_navigation_text(true); like this:

PerchSystem::set_var('lang', perch_pages_navigation_text(true));

Hi Drew,

That has worked perfectly. Is there any documentation on this:

perch_pages_navigation_text(true)

So I can understand it better?

Thanks, Andy

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, I searched the docs for the function name:

https://docs.grabaperch.com/docs/navigation/perch-pages-navigation-text/

Thanks Drew, it was me being thick, I searched but on the forum rather than docs... :(

Sorry Drew,

Related to this, can we do the same sort of thing with a select field? I need to populate the options="" on a perch form with the perch_pages_navigation_text

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that should work with the options attribute too... just add your tag as the attribute value. Content tags are parsed before form tags.

Hi Drew,

I just can't get this to work whatever I do :(

I have a static page with the following code:

<?php
  perch_form('general_enquiry_form.html');
?>

and the template contains this select field:

<perch:input type="select" options="<perch:content id="centre-name" type="text" label="Centre Name" />" id="test" label="Centre" />

...but the select options are not showing.

I have alson tried:

<perch:input type="select" options="<perch:pages id="pageNavText" />" id="test" label="Centre" />

but this doesn't work either.

Any ideas?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ah, try using perch_content_custom() to display the form. perch_form() won't do the content substitution.

Hi Drew,

Im nearly there (I think). I am now using this code on the page:

<?php
  PerchSystem::set_var('centreName', perch_pages_navigation(array('navgroup' => 'business-centres','template' => 'abc.html','levels' => 1,),true));
  perch_content_custom('Enquiry Form', array(
  'template'=>'general_enquiry_form.html',
  ));
?>

and this in the template:

<perch:input type="select" options="<perch:content id="centreName" />" id="centreName" label="Centre" />

...but I'm getting all of the results in as one option in the select list.

Drew McLellan

Drew McLellan 2638 points
Perch Support

When you view source on the HTML page, what does the select field look like?

Hi Drew,

<select id="centreName" name="centreName">
<option selected="selected" value="Business Centre OneBusiness Centre Two">Business Centre OneBusiness Centre Two</option
</select>
Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like your template is missing a comma.

Spot on, thanks Drew... I need to learn to look for the simple stuff!