Example #1
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // shorten fields
         $txtName = $this->frm->getField('name');
         // validate fields
         $txtName->isFilled(BL::err('NameIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // build item
             $item['name'] = $txtName->getValue();
             $item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
             // insert the item
             $item['id'] = BackendMailmotorModel::insertCampaign($item);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_add_campaign', array('item' => $item));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('Campaigns') . '&report=added&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']);
         }
     }
 }