/** * 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(); // shorten fields $txtName = $this->frm->getField('name'); $rbtDefaultForLanguage = $this->frm->getField('default'); // validate fields if ($txtName->isFilled(BL::err('NameIsRequired'))) { if ($txtName->getValue() != $this->record['name'] && BackendMailmotorModel::existsGroupByName($txtName->getValue())) { $txtName->addError(BL::err('GroupAlreadyExists')); } } // no errors? if ($this->frm->isCorrect()) { // build item $item['id'] = $this->id; $item['name'] = $txtName->getValue(); $item['language'] = $rbtDefaultForLanguage->getValue() === '0' ? null : $rbtDefaultForLanguage->getValue(); $item['is_default'] = $rbtDefaultForLanguage->getChecked() ? 'Y' : 'N'; // update the item BackendMailmotorCMHelper::updateGroup($item); // check if all default groups were set BackendMailmotorModel::checkDefaultGroups(); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_edit_group', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('groups') . '&report=edited&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']); } } }