Example #1
0
 public function getComponent($name, $need = TRUE)
 {
     if (isset($this->dict[$name])) {
         $name = $this->dict[$name];
     }
     return parent::getComponent($name, $need);
 }
Example #2
0
 public function formSucceed(Form $form, $values)
 {
     $filter = [];
     foreach ($form->getComponent('filter')->getControls() as $component) {
         if ($component->name == 'limit') {
             if ($values->filter->limit != 50) {
                 $filter['limit'] = $values->filter->limit;
             }
         } elseif (!$component instanceof SubmitButton) {
             if (!empty($values->filter->{$component->name})) {
                 $filter[$component->name] = $values->filter->{$component->name};
             }
         }
     }
     if (!empty($filter)) {
         $this->filter = serialize($filter);
     } else {
         $this->filter = null;
     }
     $this->redirect('this');
 }
 /**
  * @param Form $form
  */
 public function colorSelectFormSubmitted(Form $form)
 {
     $values = $form->getValues();
     $subquestion = $this->subquestion_service->saveBaseProperties($values);
     // rekonstrukce puvodnich id_pages
     $id_page = $this->question_service->get($subquestion->id_question)->id_page;
     $options = array();
     if ($subquestion->id_page_related !== null) {
         $related = $this->page_service->getRelatedPagesByFilter(new PageRelated(array(PageRelated::IDS_PAGE_RELATED => array($subquestion->id_page_related), \App\Base\Filter::GROUP_BY => true)));
         if (count($related) === 1 && $related[0] !== null) {
             $pages = $related[0]->getPagesRelatedAsArray();
             $options = array($pages[0]->getPage()->id_page => "", $pages[1]->getPage()->id_page => "");
         }
     }
     //        $pages = $this->page_service->getRelatedPages($id_page);
     //        $options = array($id_page=>"",$pages[0]->id_page);
     $form->getComponent("id_pages")->setItems($options);
     $values = $form->getValues();
     $subquestion->state = $values->id_pages === (int) $id_page ? \App\Model\Subquestion::STATE_CORRECT : \App\Model\Subquestion::STATE_WRONG;
     $subquestion->answer = $values->id_pages;
     $this->subquestion_service->save($subquestion);
     if ($form['cancel']->isSubmittedBy()) {
         $this->redirect("Survey:final");
     }
     if ($this->sessionSection->id_respondent === null) {
         $this->sessionSection->id_question = $subquestion->id_question;
         $this->redirect("Survey:personal");
     } else {
         $this->redirect("Survey:question");
     }
 }