コード例 #1
0
ファイル: ContactForm.php プロジェクト: tysonrude/bloom7
 public function onSaveForm()
 {
     $settings = \Rafie\Contactform\Models\ContactFormSettings::instance();
     $request = \App::make('request');
     if ($settings->google_captcha_disabled == '1' && !$this->hasGoogleCaptcha($request)) {
         return Redirect::back()->with(['error' => true, 'messages' => ['Re-captcha is not set! Are you a Robot?']]);
     }
     $data = $this->cleanRequestData($request->all());
     $form = Form::findOrFail($data['fid']);
     $rules = $this->buildValidationRules($form->fields);
     $customMessages = $this->buildCustomValidationMessages($form->messages);
     $messages = $this->isValidUserInput($data, $rules, $customMessages);
     if ($messages !== true) {
         return Redirect::back()->with(['error' => true, 'messages' => $messages]);
     }
     $this->saveAttachments($data);
     // save user submission
     $mailTemplate = Email::find($data['tid']);
     $userForm = new UserForm();
     $userForm->form_id = $form->id;
     $userForm->fields = json_encode($data);
     $userForm->request_headers = json_encode($request->server->all());
     $userForm->save();
     // fire event to send emails
     Event::fire('RAFIE.FormPosted', [$userForm, $mailTemplate]);
     // redirect with success
     return Redirect::to('message-success');
 }
コード例 #2
0
ファイル: FormComponent.php プロジェクト: tysonrude/bloom7
 /**
  * @param array $classes
  */
 public function __construct(array $classes)
 {
     $this->settings = \Rafie\ContactForm\Models\ContactFormSettings::instance();
     $this->useBootstrap = $this->settings->use_bootstrap_css && $this->settings->use_bootstrap_css !== '0';
     if ($this->useBootstrap) {
         $classes[] = 'form-group';
     }
     $classes[] = 'form-item';
     $this->classes = implode(' ', $classes);
 }