Example #1
0
 protected function attached($form)
 {
     parent::attached($form);
     $this->sessionSection = $sessionSection = $this->getName() . 'textCaptcha';
     if ($this->session->hasSection($sessionSection) && $this->session->getSection($sessionSection)->questionId > 0) {
         $questionId = $this->session->getSection($sessionSection)->questionId;
     } else {
         $this->session->getSection($sessionSection)->questionId = $questionId = rand(0, count($this->questions) - 1);
     }
     $this->setRequired();
     $this->addRule(Form::EQUAL, 'Neodpověděl(a) jste správně na otázku.', $this->questions[$questionId]['answer']);
 }
 /**
  * This method will be called when the component (or component's parent)
  * becomes attached to a monitored object. Do not call this method yourself.
  *
  * @param \Nette\ComponentModel\IComponent $form form
  * @return void
  */
 protected function attached($form)
 {
     parent::attached($form);
     if ($form instanceof Form) {
         $form[$this->getUidFieldName()] = new HiddenField();
     }
 }