Example #1
0
 /**
  * Validate the form
  *
  * @return void
  */
 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();
         // validate fields
         $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
         // no errors?
         if ($this->frm->isCorrect()) {
             // first, build the category array
             $category['id'] = (int) $this->id;
             $category['title'] = (string) $this->frm->getField('title')->getValue();
             $category['language'] = (string) BL::getWorkingLanguage();
             $category['hidden'] = (string) $this->frm->getField('hidden')->getValue();
             // ... then, update the category
             $category_update = BackendGalleryModel::updateCategory($category);
             // trigger event
             BackendModel::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $category));
             // everything is saved, so redirect to the overview
             $this->redirect(BackendModel::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($category['title']) . '&highlight=row-' . $category['id']);
         }
     }
 }