Hello,
Im using SS 3.02, with a contactform class, uses a template to send the form data.
Where do i store the email template?
this is all wrong:
/themes/Mytheme/templates/Email/contactEmail.ss
/themes/Mytheme/templates/Includes/contactEmail.ss
/themes/Mytheme/templates/Layout/contactEmail.ss
/mysite/templates/Email/contactEmail.ss
/mysite/templates/contactEmail.ss
So what is the correct place?
<?php
class ContactPage extends Page{
static $db = array(
'Mailto' => 'Varchar(100)',
'SubmitText' => 'HTMLText',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.OnSubmission", new TextField('Mailto', 'Email submissions to'));
$fields->addFieldToTab("Root.OnSubmission", new HTMLEditorField('SubmitText', 'Text on Submission'));
return $fields;
}
}
class ContactPage_Controller extends Page_Controller{
static $allowed_actions = array(
'ContactForm'
);
function ContactForm(){
$fields = new FieldList(
new TextField('Budget', 'Budget'),
new TextField('Naam', 'Naam'),
new TextField('Email', 'Email'),
new TextareaField('Bericht', 'Bericht')
);
$actions = new FieldList(
new FormAction('SendContactForm', 'Verstuur')
);
$validator = new RequiredFields('Naam', 'Email', 'Bericht');
return new Form($this, 'ContactForm', $fields, $actions, $validator);
}
function SendContactForm($data, $form){
$From = $data['Email'];
$To = $this->Mailto;
$Subject = "Bericht via contactformulier";
$email = new Email($From, $To, $Subject);
$email->setTemplate('ContactEmail');
$email->populateTemplate($data);
$email->send();
Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
}
//The function to test whether to display the Submit Text or not
public function Success(){
return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
}
}
The error is:
[user warning] None of these templates can be found in theme 'Mytheme' ContactEmail.ss
Line 633 in SSViewer.php