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?
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?
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/
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.
Template -> application/mail/block_form_templateName
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);
Will this work with 8.1 and newer?
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.