Example #1
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['subject']->isFilled(BL::err('FieldIsRequired'));
         $fields['text']->isFilled(BL::err('FieldIsRequired'));
         $this->meta->validate();
         if ($this->frm->isCorrect()) {
             $item['meta_id'] = $this->meta->save();
             $item['template_id'] = $fields['template_id']->getValue();
             $item['subject'] = $fields['subject']->getValue();
             $item['text'] = $fields['text']->getValue();
             $item['hidden'] = $fields['hidden']->getValue();
             $item['show_on_website'] = $fields['show_on_website']->getValue();
             $item['language'] = BL::getWorkingLanguage();
             $item['id'] = BackendMailengineModel::insert($item);
             BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['subject'], 'text' => $item['text']));
             BackendModel::triggerEvent($this->getModule(), 'after_add', $item);
             $this->redirect(BackendModel::createURLForAction('index') . '&report=added&highlight=row-' . $item['id']);
         }
     }
 }