Forum
How to use an ID from one page on a form on another page - skip template?
Hi
I've setup a three page list and detail, for a careers section.
- Page 1 list jobs
- Page 2 show selected job
- Page 3 shows job title (pulled in from page 2) and an application form
This works; but I'd like to send the job title along with the form submission
The id
of the job title is id="job-role"
I tried adding this to the form like this:
<perch:input label="Job Reference" type="hidden" id="job-role" />
But unfortunately it doesn't work... The label appears in the forms control panel but the content is blank.
I think the way to do it would be to use skip-template
, but I'm not sure how to implement it...
I'm using the following routes:
- careers/[slug:s]
- careers/[slug:s]/[apply:apply]
Here's the list and detail code:
if (perch_get('apply')) {
// Shows job title and an application form
// URL: /careers/job-name-here/apply
perch_collection('Careers', array(
'template' =>'job-form.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('s'),
'count' => 1,
));
}
elseif (perch_get('s')) {
// Displays single job in careers collection filtered on slug
// URL: /careers/job-name-here/
perch_collection('Careers', array(
'template' =>'job-detail.html',
'filter' => 'slug',
'match' => 'eq',
'value' => perch_get('s'),
'count' => 1,
));
}
else {
// Lists all jobs in careers collection
// URL: /careers/
echo'<div class="div pad main">';
perch_collection('Careers', array(
'template' =>'job-list.html',
));
}
Hope you can help
If you put this in your form, what happens?
Hi Drew
Doesn't work unfortunately.
label="Job Reference"
is still blank when the form is submitted. Any further ideas?There is something strange happening with the form, that may or not be related.
Just to recap:
The form is on the third page of the list and detail setup.
The form doesn't validate. When I press submit the page reloads and goes back to page 1? Even though there are required fields on the form?
When the fields are filled in, the form successfully submits (shows up in the CMS) but the
perch:success
message isn't shown. The page reloads and goes back to page 1.If you view source, do you see the hidden field? Does it have a value?
Yes, this is what's in the source:
This is what's in the template, for some reason it's different:
I've changed the template code back to:
It shows up in the source:
I think the problem might be related to the way I'm adding the form to the page...
The
if
part of the statement uses a template called `job-form.html'job-form.html
usesperch:template
to pull the form in:I'll try and add the form another way...
Try:
Hi Drew
I got the form to submit the
id="job-role"
I was able to modify something you helped me with previously.
I used
perch_content_create
to create the form regionI then used
skip-template
in theif
statementWithin the job form I added this:
All the information from the form (including the hidden
id
) gets submitted.I'm still having problems with the validation and the
success
message. The form still reloads the page without showing either validation errors or success messageAs this is a different problem I'll create a new thread.