Hi guys, I have a simple form which appears on every product page of a site, I would like it so that when the form is submitted the title of the page on which the form is submitted from appears in the email. How can this be done? Here is the current code for the form. Thanks in advance for any help!
function ContactForm() {
// Create fields
$fields = new FieldSet(
new EmailField('Email'),
new TextareaField('Message')
);
// Create actions
$actions = new FieldSet(
new FormAction('doContact', 'Submit')
);
$validator = new RequiredFields('Email', 'Message');
return new Form($this, 'ContactForm', $fields, $actions, $validator);
}
function doContact($data, $form) {
$email = new Email();
$email->setTemplate('ContactPage_Email');
$email->setSubject('Someone submitted the contact form');
$email->setFrom('admin@somesite.com');
$email->setTo('howardgrigg@gmail.com');
$email->populateTemplate($data);
$email->send();
$form->sessionMessage('Thanks for contacting us. We will endeavour to get in touch with you as soon as possible!', 'good');
Director::redirectBack();
}