'doSend'); public function __construct($Doc, $DBObj) { $this->DB_Grid($Doc, $DBObj); } public function _bindFormFields($form) { $form->addElement('text', 'first_name', 'First Name'); $form->addElement('text', 'last_name', 'Last Name'); $form->addElement('text', 'address', 'Street Address'); $form->addElement('text', 'city', 'City'); $form->addElement('text', 'state', 'State'); $form->addElement('text', 'zip', 'Zip'); $form->addElement('text', 'phone', 'Phone'); $form->addElement('text', 'email', 'Email Address'); $date_options = array( 'language' => 'en', 'format' => 'dMY', 'minYear' => 1900, 'maxYear' => (int)date("Y") + 10, 'addEmptyOption' => false, 'emptyOptionValue' => '', 'emptyOptionText' => ' ', 'optionIncrement' => array('i' => 1, 's' => 1) ); $form->addElement('date', 'birthday', 'Birthday', $date_options); //vdie($form->getRegisteredRules()); $form->addRuleRequired(array('first_name', 'last_name', 'email', 'birthday')); $form->addRule('email', 'Email Address is wrong', 'email'); $form->addRule('birthday', 'Birthday is wrong', 'date_check'); return $form; } public function _getNewForm() { $form = $this->_getBaseForm(); $form = $this->_bindFormFields($form); return $form; } public function doSend() { $form = $this->_getNewForm(); if ($form->validate()) { $data = $form->exportValues(); $this->_send($data); exit(); } else { echo implode("\n", $form->_errors); exit(); //$this->renderForm($form); } return true; } protected function _send($data) { $nl = "\n"; $message = "You've received a new Newsletter form submission from Town Hall Brewery web site. First Name: {$data['first_name']} Last Name: {$data['last_name']} Address: {$data['address']} State: {$data['state']} City: {$data['city']} Zip: {$data['zip']} Phone: {$data['phone']} Email: {$data['email']} Birthday: {$data['birthday']['M']}/{$data['birthday']['d']}/{$data['birthday']['Y']} "; $emails = Settings::getAdminEmails(); $headers = 'From: ' . Settings::get('admin_email_from') . $nl; if (is_array($emails) && !empty($emails)) { foreach ($emails as $email) { mail($email, "TownHallBrewery Newsletter form submission", $message, $headers); } } return true; } }