Created
January 29, 2013 16:38
-
-
Save Kedrigern/4665632 to your computer and use it in GitHub Desktop.
Hrátky s form replikátorem z Nette
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Tento příklad vychází z Sandbox z http://addons.nette.org/cs/form-container-replicator | |
| * resp. správně nastavené rozlišení form replikator | |
| */ | |
| <?php | |
| use Nette\Forms\Container; | |
| use Nette\Application\UI\Form; | |
| /** | |
| * Homepage presenter. | |
| */ | |
| class HomepagePresenter extends BasePresenter | |
| { | |
| /** | |
| * @var array of some items | |
| */ | |
| private $itemsR = array( | |
| 1 => "položka 1", | |
| 2 => "položka 2", | |
| 3 => "položka 3", | |
| 4 => "položka 4", | |
| ); | |
| /** | |
| * @return Nette\Application\UI\Form | |
| */ | |
| protected function createComponentForm2() | |
| { | |
| $form = new Form; | |
| $presenter = $this; | |
| $invalidateCallback = function () use ($presenter) { | |
| /** @var \Nette\Application\UI\Presenter $presenter */ | |
| // $presenter->invalidateControl('itemsForm'); | |
| }; | |
| foreach( $this->itemsR as $id => $item ) { | |
| $form->addDynamic("items$id", function (Container $container) use ($invalidateCallback, $item) { | |
| $container->currentGroup = $container->form->addGroup("$item", FALSE); | |
| $container->addCheckbox('do', "vybrat"); | |
| }, 1); | |
| } | |
| $form->addSubmit('ok', 'ok'); | |
| $form->onSuccess[] = $this->Form2Submitted; | |
| $this['form2'] = $form; | |
| return $form; | |
| } | |
| /** | |
| * @param Nette\Application\UI\Form $form | |
| */ | |
| public function Form2Submitted(Form $form) | |
| { | |
| $values = $form->getValues(true); | |
| echo("<pre>" . print_r($values, true) . "</pre>"); | |
| die(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment