Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static $allowed_actions = array(
- 'ApplicationForm'
- );
- function ApplicationForm() {
- $fields = new FieldSet(
- new TextField('Name', 'Name*'),
- new EmailField('Email', 'Email*'),
- new TextareaField('Comments','Comments*')
- );
- // Create action
- $actions = new FieldSet(
- new FormAction('SendContactForm', 'Send')
- );
- // Create Validators
- $validator = new RequiredFields('Name', 'Email', 'Comments');
- return new Form($this, 'ContactForm', $fields, $actions, $validator);
- }
- function SendContactForm($data, $form) {
- $From = $data['Email'];
- $To = "teddy@webintegrations.co.uk";
- $Subject = "Website Contact message";
- $email = new Email($From, $To, $Subject);
- $email->setTemplate('ContactEmail');
- $email->populateTemplate($data);
- $email->send();
- Director::redirect($this->Link("?success=1"));
- }
- public function Success() {
- return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement