/**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['title']->isFilled(BL::err('FieldIsRequired'));
         $fields['from_email']->isFilled(BL::err('FieldIsRequired'));
         $fields['from_name']->isFilled(BL::err('FieldIsRequired'));
         $fields['reply_email']->isFilled(BL::err('FieldIsRequired'));
         $fields['reply_name']->isFilled(BL::err('FieldIsRequired'));
         $fields['template']->isFilled(BL::err('FieldIsRequired'));
         $fields['from_email']->isEmail(BL::err('EmailIsInvalid'));
         $fields['reply_email']->isEmail(BL::err('EmailIsInvalid'));
         if ($this->frm->isCorrect()) {
             $item['title'] = $fields['title']->getValue();
             $item['from_email'] = $fields['from_email']->getValue();
             $item['from_name'] = $fields['from_name']->getValue();
             $item['reply_email'] = $fields['reply_email']->getValue();
             $item['reply_name'] = $fields['reply_name']->getValue();
             $item['template'] = $fields['template']->getValue();
             $item['css'] = $fields['css']->getValue();
             $item['hidden'] = $fields['hidden']->getValue();
             BackendMailengineModel::updateTemplate($this->id, $item);
             $item['id'] = $this->id;
             BackendModel::triggerEvent($this->getModule(), 'after_edit_template', $item);
             $this->redirect(BackendModel::createURLForAction('templates') . '&report=edited&highlight=row-' . $item['id']);
         }
     }
 }