Presenter
<?php public function renderAdd($active = false) { $session = $this->session->getSection('mySess'); if ($active != true) { $session->remove(); } else { if (isset($session)) { $this['myForm']->setDefaults($session->form); } } } public function createComponentMyForm($name) { $session = $this->session->getSection("mySess"); $rows = (isset($session->form['rows'])) ? $session->form['rows'] : 2; //def je 2 $form = new Nette\Application\UI\Form; $ints = array(); for($i = 0; $i < 10; $i++) { $ints[$i] = $i; } $form->addSelect('rows', "Textboxů:", $ints)->setDefaultValue($rows); $form->addSubmit("submit", "Vytvořit textboxy") ->setValidationScope(NULL) ->onClick[] = callback($this, "fillTextboxs"); $textboxs = $form->addContainer('textboxs'); for ($i = 1; $i <= $rows; $i++) { $sec = $textboxs->addContainer($i); $sec->addText('inp', 'Input ' . $i . ':'); } return $form; } public function fillTextboxs() { $session = $this->session->getSection('mySess'); $session->form = $this['myForm']->getValues(); $this->redirect('this', array('active' => TRUE)); } ?>
add.latte
{control myForm}