Beispiel #1
0
 /**
  * Render the templates
  *
  * @param \Nette\Forms\Form $form
  * @return void
  */
 public function render(\Nette\Forms\Form $form)
 {
     if ($form === $this->form) {
         // don't forget for second run, @hosiplan! ;)
         foreach ($this->form->getControls() as $control) {
             $control->setOption('rendered', FALSE);
         }
         echo $this->template;
         return;
     }
     // Store the current form instance
     $this->form = $form;
     // Translator available?
     if ($translator = $form->getTranslator()) {
         // intentional =
         $this->template->setTranslator($translator);
     }
     // Pre-proccess form
     $errors = $form->getErrors();
     foreach ($form->getControls() as $control) {
         $control->setOption('rendered', FALSE);
         if (!$control->getOption('blockname', FALSE)) {
             $ex = explode('\\', get_class($control));
             $control->setOption('blockname', end($ex));
         }
         if ($this->errorsAtInputs) {
             $errors = array_diff($errors, $control->errors);
         }
     }
     // Assign to template
     $this->template->form = $form;
     $this->template->errors = $errors;
     $this->template->renderer = $this;
     $this->template->errorsAtInputs = $this->errorsAtInputs;
     // And echo the output
     echo $this->template;
 }