1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
 * Defines the ArticleHolder page type
 */
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(
		 "[email protected]" => "Report a Student Absence",
		 "[email protected]" => "Contact the Head's PA",
		 "[email protected]" => "Problem with Fronter/VLE",
		 "[email protected]" => "Contact a Member of Staff",
		 "[email protected]" => "General Enquiry",
		 "[email protected]" => "Problem with Parentmail",
		 "[email protected]" => "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/");

 } 


}

?>