Backend\Modules\Search\Actions\AddSynonym::validateForm PHP Метод

validateForm() приватный Метод

Validate the form
private validateForm ( )
    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 field
            $this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired'));
            $this->frm->getField('term')->isFilled(BL::err('TermIsRequired'));
            if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) {
                $this->frm->getField('term')->addError(BL::err('TermExists'));
            }
            // no errors?
            if ($this->frm->isCorrect()) {
                // build item
                $item = array();
                $item['term'] = $this->frm->getField('term')->getValue();
                $item['synonym'] = $this->frm->getField('synonym')->getValue();
                $item['language'] = BL::getWorkingLanguage();
                // insert the item
                $id = BackendSearchModel::insertSynonym($item);
                // trigger event
                BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item));
                // everything is saved, so redirect to the overview
                $this->redirect(BackendModel::createURLForAction('Synonyms') . '&report=added-synonym&var=' . rawurlencode($item['term']) . '&highlight=row-' . $id);
            }
        }
    }