/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->meta->setUrlCallback('BackendFaqModel', 'getURLForCategory', array($this->record['id'])); $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); $this->meta->validate(); if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['language'] = $this->record['language']; $item['title'] = $this->frm->getField('title')->getValue(); $item['meta_id'] = $this->meta->save(true); // update the item BackendFaqModel::updateCategory($item); BackendModel::triggerEvent($this->getModule(), 'after_edit_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Execute the action * * @return void */ public function execute() { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // get parameters $newIdSequence = trim(SpoonFilter::getPostValue('new_id_sequence', null, '', 'string')); // list id $ids = (array) explode(',', rtrim($newIdSequence, ',')); // loop id's and set new sequence foreach ($ids as $i => $id) { // build item $item['id'] = (int) $id; // change sequence $item['sequence'] = $i + 1; // update sequence if (BackendFaqModel::existsCategory($item['id'])) { BackendFaqModel::updateCategory($item); } } // success output $this->output(self::OK, null, 'sequence updated'); }
/** * 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('name')->isFilled(BL::err('NameIsRequired')); // no errors? if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['name'] = $this->frm->getField('name')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['extra_id'] = $this->record['extra_id']; // update the item BackendFaqModel::updateCategory($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edite_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('categories') . '&report=edited-category&var=' . urlencode($item['name']) . '&highlight=row-' . $item['id']); } } }