Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. static $allowed_actions = array(
  2. 'ApplicationForm'
  3. );
  4.  
  5. function ApplicationForm() {
  6. $fields = new FieldSet(
  7. new TextField('Name', 'Name*'),
  8. new EmailField('Email', 'Email*'),
  9. new TextareaField('Comments','Comments*')
  10. );
  11.  
  12. // Create action
  13. $actions = new FieldSet(
  14. new FormAction('SendContactForm', 'Send')
  15. );
  16.  
  17. // Create Validators
  18. $validator = new RequiredFields('Name', 'Email', 'Comments');
  19. return new Form($this, 'ContactForm', $fields, $actions, $validator);
  20. }
  21.  
  22. function SendContactForm($data, $form) {
  23. $From = $data['Email'];
  24. $To = "teddy@webintegrations.co.uk";
  25. $Subject = "Website Contact message";
  26. $email = new Email($From, $To, $Subject);
  27. $email->setTemplate('ContactEmail');
  28. $email->populateTemplate($data);
  29. $email->send();
  30. Director::redirect($this->Link("?success=1"));
  31. }
  32.  
  33. public function Success() {
  34. return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement