/**
  * Form action handler for ContactInquiryForm.
  *
  * @param array $data The form request data submitted
  * @param Form $form The {@link Form} this was submitted on
  */
 function dosave(array $data, Form $form, SS_HTTPRequest $request)
 {
     $SQLData = Convert::raw2sql($data);
     $attrs = $form->getAttributes();
     if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
         // most probably spam - terminate silently
         Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
         return;
     }
     $item = new ContactInquiry();
     $form->saveInto($item);
     // $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
     $item->write();
     $mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
     $mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
     $mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
     $email = new Email($mailFrom, $mailTo, $mailSubject);
     $email->replyTo($SQLData['Email']);
     $email->setTemplate("ContactInquiry");
     $email->populateTemplate($SQLData);
     $email->send();
     // $this->controller->redirectBack();
     if ($email->send()) {
         $this->controller->redirect($this->controller->Link() . "success");
     } else {
         $this->controller->redirect($this->controller->Link() . "error");
     }
     return false;
 }
Example #2
0
 public function testBadClassInvokesDefault()
 {
     $args = array('class' => array(1, 2, 3));
     $form = new Form("default", $args);
     $defaults = $form->getDefaults();
     $attr = $form->getAttributes();
     $this->assertTrue($attr['class'] == $defaults['class']);
 }
 /**
  * Override some we can add UserForm specific attributes to the form.
  *
  * @return array
  */
 public function getAttributes()
 {
     $attrs = parent::getAttributes();
     $attrs['class'] = $attrs['class'] . ' userform';
     $attrs['data-livevalidation'] = (bool) $this->controller->EnableLiveValidation;
     $attrs['data-toperrors'] = (bool) $this->controller->DisplayErrorMessagesAtTop;
     $attrs['data-hidefieldlabels'] = (bool) $this->controller->HideFieldLabels;
     return $attrs;
 }
Example #4
0
 public static function forming(Form $form)
 {
     $output = "";
     $output .= "<" . $form->getBalise();
     foreach ($form->getAttributes() as $k => $v) {
         $output .= " {$k}=\"{$v}\"";
     }
     $output .= ">";
     foreach ($form->getElements() as $v) {
         $output .= static::process_form_elements($v);
     }
     $output .= "</" . $form->getBalise() . ">";
     return $output;
 }