Include Page Title Upon Form Submission

Permalink
I am getting ready to build a site in 8.1, and will need to make use of forms. I would like to use just one form that will be included on a specific page type.

When the user submits the form, I will need to include the page title that visitor is currently on, which will be sent to the recipient.

How would I include the current page title upon form submission?

PineCreativeLabs
 
hutman replied on at Permalink Reply
hutman
You could probably override the Form block and add it.

You would have to override the db.xml to add a field cID, then override the controller to populate that field, and then the dashboard display to display the page title.
c5dragon replied on at Permalink Reply
c5dragon
C5.7.5.13 (or legacy form v8)

I use this on a product page type.
In the form view you add a hidden input with the pagename or whatever value you want.

Form View -> application/blocks/form/
<?php $c = Page::getCurrentPage();?>
<input name="pID" type="hidden" value="<?php echo $c->getCollectionName() ?>" />

Controller -> application/blocks/form/
In the form controller you read that value. And use a different template that can use this value inside its template.
$mh->addParameter('pID', $pID);
// Custom Template
$mh->load('block_form_templateName');

Template -> application/mail/block_form_templateName
<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$submittedData='';
foreach($questionAnswerPairs as $questionAnswerPair){
   $submittedData .= $questionAnswerPair['question']."\r\n".$questionAnswerPair['answerDisplay']."\r\n"."\r\n";
}
$body = t("
%s - %s
%s
Beste regards,
Contact name | Website url
", $pID, $formName, $submittedData);
PineCreativeLabs replied on at Permalink Reply
PineCreativeLabs
Will this work with 8.1 and newer?