Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected function createComponentForm($name)
- {
- $this[$name] = $form = new Nette\Application\UI\Form;
- $pairs = array('a', 'b', 'c'); // třeba z databáze
- $form->addSelect('one', 'One', $pairs);
- $pairsTwo = $this->model->findBy($form['one']->value); // vytahne zavisle
- // $pairsTwo = array('d', 'e', 'f');
- $form->addSelect('two', 'Two', $pairsTwo);
- }
- #### editace
- public function actionEdit($id = 0)
- {
- $this->entity = $this->model->get($id);
- if (!$this->entity) {
- throw new Nette\Application\BadRequestException;
- }
- }
- protected function createComponentEditForm($name)
- {
- if (!$this->entity) {
- throw new Nette\Application\BadRequestException;
- }
- $this[$name] = $form = new Nette\Application\UI\Form;
- $pairs = array('a', 'b', 'c'); // třeba z databáze
- $form->addSelect('one', 'One', $pairs)
- ->setDefaultValue($this->entity->one);
- $pairsTwo = $this->model->findBy($form['one']->value); // vytahne zavisle
- // $pairsTwo = array('d', 'e', 'f');
- $form->addSelect('two', 'Two', $pairsTwo)
- ->setDefaultValue($this->entity->two);
- }
Advertisement
Add Comment
Please, Sign In to add comment