<?php
class ContactPage extends Page {
static $db = array(
);
static $defaults = array(
);
}
class ContactPage_Controller extends Page_Controller {
function ContactForm() {
$fields = new FieldSet(
new TextField('Name', 'Name'),
new ListboxField(
$name = "Subject",
$title = "Contact Subject",
$source = array(
"email1@site.com" => "Report a Student Absence",
"email2@site.com" => "Contact the Head's PA",
"email3@site.com" => "Problem with Fronter/VLE",
"email4@site.com" => "Contact a Member of Staff",
"email5@site.com" => "General Enquiry",
"email6@site.com" => "Problem with Parentmail",
"email7@site.com" => "Other",
),
$value = 'Please Select Subject'
),
new TextField('Other', 'Other'),
new TextField('Address', 'Address'),
new TextField('Address1', ' '),
new TextField('Postcode', 'Postcode'),
new TextField('Telephone', 'Telephone'),
new EmailField('Email', 'Email'),
new TextareaField('Message', 'Message'),
new RecaptchaField('MyCaptcha')
);
$actions = new FieldSet(
new FormAction('doContactSubmit', 'Submit')
);
$validator = new RequiredFields(
'Name','Email', 'Telephone', 'Message', 'Subject'
);
$form = new Form($this, 'ContactForm', $fields, $actions, $validator);
return $form;
}
function doContactSubmit($data, $form) {
$email = new Email_Template();
$email->setTo($data['Subject']);
$email->setFrom($data['Email']);
$email->setSubject('Website Contact');
$email->ss_template = "ContactPageEmail";
$email->populateTemplate($data);
$email->send();
Director::redirect("Thankyou/");
}
}
?>