示例#1
0
 public function validateInput($input)
 {
     if (!array_key_exists('branching', $input)) {
         throw new \Jazzee\Exception('Invalid input on Branching page: ' . var_export($input, true));
     }
     $page = $this->_applicationPage->getPage()->getChildById($input['branching']);
     $this->branchingForm($page);
     if ($input['level'] == 1) {
         return false;
     }
     return parent::validateInput($input);
 }
示例#2
0
 public function validateInput($input)
 {
     if (!array_key_exists('level', $input)) {
         $input['level'] = false;
     }
     switch ($input['level']) {
         case 'search':
             if ($input = $this->getForm()->processInput($input)) {
                 $choices = array();
                 $searchTerms = $input->get('schoolSearch');
                 $resultsCount = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\School')->getSearchCount($searchTerms);
                 if ($resultsCount > 50) {
                     $this->_form->getElementByName('schoolSearch')->addMessage('Your search returned too many results, please try again with more detail.');
                 } else {
                     if ($resultsCount == 0) {
                         $this->_controller->addMessage('info', 'We were not able to find any schools that matched your search, you can search again or add a new school to our system.');
                     } else {
                         $schools = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\School')->search($searchTerms);
                         foreach ($schools as $school) {
                             $choices[$school->getId()] = $school->getName();
                         }
                     }
                     $this->pickSchoolForm($choices);
                 }
                 return false;
             } else {
                 $this->_controller->addMessage('error', self::ERROR_MESSAGE);
                 return false;
             }
             break;
         case 'pick':
             if (!empty($input['pickSchoolId']) and $selectedSchool = $this->getSchoolById($input['pickSchoolId'])) {
                 $this->_controller->setVar('schoolName', $selectedSchool->getName());
                 $this->pageForm($input);
                 $this->_form->newHiddenElement('schoolId', $selectedSchool->getId());
             } else {
                 $this->newSchoolForm();
             }
             return false;
             break;
         case 'new':
             $this->newSchoolForm();
             if ($this->getForm()->processInput($input)) {
                 $this->pageForm($input);
             } else {
                 $this->_controller->addMessage('error', self::ERROR_MESSAGE);
             }
             return false;
             break;
         case 'complete':
             if (array_key_exists('schoolId', $input)) {
                 if (!$this->getSchoolById($input['schoolId'])) {
                     $this->_form = $this->makeForm();
                     $this->_controller->addMessage('error', 'There was a problem with your school selection.  You will need to search again.');
                     return false;
                 }
             } else {
                 $this->newSchoolForm();
                 if (!$this->getForm()->processInput($input)) {
                     $this->_controller->addMessage('error', self::ERROR_MESSAGE);
                     return false;
                 }
             }
             $this->pageForm($input);
             return parent::validateInput($input);
             break;
         default:
             throw new \Jazzee\Exception('Invalid Input on Education Page: ' . var_export($input, true));
     }
 }