/** * Validates the settings form */ private function validateForm() { // form is submitted if ($this->frm->isSubmitted()) { // validate module weights foreach ($this->modules as $i => $module) { // only if this module is enabled if ($this->frm->getField('search_' . $module['module'])->getChecked()) { // valid weight? $this->frm->getField('search_' . $module['module'] . '_weight')->isDigital(BL::err('WeightNotNumeric')); $this->modules[$i]['txtError'] = $this->frm->getField('search_' . $module['module'] . '_weight')->getErrors(); } } // form is validated if ($this->frm->isCorrect()) { // set our settings $this->get('fork.settings')->set($this->getModule(), 'overview_num_items', $this->frm->getField('overview_num_items')->getValue()); $this->get('fork.settings')->set($this->getModule(), 'autocomplete_num_items', $this->frm->getField('autocomplete_num_items')->getValue()); $this->get('fork.settings')->set($this->getModule(), 'autosuggest_num_items', $this->frm->getField('autosuggest_num_items')->getValue()); $this->get('fork.settings')->set($this->getModule(), 'use_sitelinks_search_box', $this->frm->getField('use_sitelinks_search_box')->isChecked()); // module search foreach ((array) $this->modules as $module) { $searchable = $this->frm->getField('search_' . $module['module'])->getChecked() ? 'Y' : 'N'; $weight = $this->frm->getField('search_' . $module['module'] . '_weight')->getValue(); // insert, or update BackendSearchModel::insertModuleSettings($module, $searchable, $weight); } // trigger event BackendModel::triggerEvent($this->getModule(), 'after_changed_settings'); // redirect to the settings page $this->redirect(BackendModel::createURLForAction('Settings') . '&report=saved'); } } }