Form submission from specific page

Permalink
Hi, I have a 'Jobs' page with all the jobs as sub pages. I would like people to be able to apply to a job by submitting a form from a job they are interested in. Is there a way to send a 'hidden' page title along with the form submission so I know which Job they are interested in?

The best option would be to have 1 form (maybe in a stack or a popup?) that works for all pages...

Let me know and thanks!
Luca

ZillionProductions
 
c5dragon replied on at Permalink Reply
c5dragon
C5.7 (or v8 legacy)

Files in application/form folder:
controller.php
mini_survey.php
view.php

Change the namespace in controller and mini_survey to Application\Block\Form

In the application/blocks/form/controller.php you can add: (around line 576)
$mh = Core::make('helper/mail');
$mh->to($this->recipientEmail);
$mh->from($formFormEmailAddress);
$mh->replyto($replyToEmailAddress);
$mh->addParameter('formName', $this->surveyName);
$mh->addParameter('questionSetId', $this->questionSetId);
$mh->addParameter('questionAnswerPairs', $questionAnswerPairs);
$service = Core::make('helper/security');
$pID = $service->sanitizeString($_POST['pID']);
$mh->addParameter('pID', $pID);
$mh->load('block_form_submission');
$mh->setSubject(t('Form Submission - %1$s - %2$s', $this->surveyName, $pID));
//echo $mh->body.'<br>';
@$mh->sendMail();

In the application/blocks/form/view.php you need to add (at the end with the rest of the hidden fields):
<?php $c = Page::getCurrentPage();?>
<input name="pID" type="hidden" value="<?php echo $c->getCollectionName() ?>" />

In application/mail add the template -> block_form_submission.php
<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$submittedData='';
foreach($questionAnswerPairs as $questionAnswerPair){
   $submittedData .= $questionAnswerPair['question']."\r\n".$questionAnswerPair['answerDisplay']."\r\n"."\r\n";
} 
$formDisplayUrl=URL::to('/dashboard/reports/forms') . '?qsid='.$questionSetId;
$body = t("
There has been a submission of the form %s on the page %s through your concrete5 website.
%s
To view all of this form's submissions, visit %s 
", $formName, $pID, $submittedData, $formDisplayUrl);


You can copy the files from concrete/blocks/form/ to the application/blocks/form folder
ZillionProductions replied on at Permalink Reply
ZillionProductions
Thanks! Could you maybe elaborate a little more on where to add the code exactly?
c5dragon replied on at Permalink Reply
c5dragon
Edited my previous post.
ZillionProductions replied on at Permalink Reply
ZillionProductions
Hmz.. I did everything you wrote and cleared the cache, but nothing changed... Any other suggestions?
c5dragon replied on at Permalink Reply
c5dragon
Added the complete code.
You can even change the mail template.