Hello,
I have edited product.php and added a simple contact form from ssbits.com, so on every product page there is a contact form.
The only problem is that i want the product title (and mayby some other variables like price etc) to send with the e-mail.
Im trying this by adding the product title to the value of a textfield and sending this textfield with the email.
The fields are sending the data that is inserted, expect the variable title(its not showing in the textfield). I dont really know how to add this variable to the form/data. Any help would be great.
Here is the code that I've added to product.php:
class Product_Controller extends Page_Controller {
static $allowed_actions = array(
'ReageerForm'
);
function ReageerForm() {
// Create fields
$fields = new FieldSet(
new TextField('Title', 'Title', $value = $Title),
new TextField('Bedrijfsnaam', 'Bedrijfsnaam'),
new TextField('Naam', 'Naam'),
new EmailField('Email', 'Email'),
new TextField('Telefoon', 'Telefoon'),
new TextField('Onderwerp', 'Onderwerp'),
new TextareaField('Bericht','Bericht')
);
// Create action
$actions = new FieldSet(
new FormAction('SendReageerForm', 'Verzenden')
);
// Create Validators
$validator = new RequiredFields('Naam', 'Telefoon', 'Onderwerp', 'Bericht', 'Email');
return new Form($this, 'ReageerForm', $fields, $actions, $validator);
}
function SendReageerForm($data, $form, $title) {
//Set data
$From = $data['Email'];
$To = $this->Mailto;
$To = "test@test.nl";
$Subject = "Reactie Product";
$email = new Email($From, $To, $Subject);
//set template
$email->setTemplate('reageerEmail');
//populate template
$email->populateTemplate($data);
//send mail
$email->send();
//return to submitted message
Director::redirect($this->Link("?success=1"));
}
Thank you in advance for the help you can provide.