Created
August 27, 2012 08:56
-
-
Save vojtech-dobes/3486768 to your computer and use it in GitHub Desktop.
Independent forms in Nette: UI\Form x UI\Control
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
<?php | |
use Nette\Application\UI; | |
class Form extends UI\Control | |
{ | |
protected function createComponentForm() | |
{ | |
$form = new UI\Form; | |
$form->addText('foo'); | |
$form->addSubmit('send'); | |
return $form; | |
} | |
public function render() | |
{ | |
$this->template->setFile(__DIR__ . '/formTemplate.latte'); | |
$this->template->render(); | |
} | |
} |
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
<?php | |
use Nette\Application\UI; | |
use Nette\Latte\Engine; | |
use Nette\Templating\FileTemplate; | |
class Form extends UI\Form | |
{ | |
protected function attached($parent) | |
{ | |
parent::attached($parent); | |
if (!$parent instanceof UI\Presenter) return; | |
$this->addText('foo'); | |
$this->addSubmit('send'); | |
} | |
public function render() | |
{ | |
$template = new FileTemplate(__DIR__ . '/formTemplate.latte'); | |
$template->registerFilter(new Engine); | |
$template->form = $this; | |
$template->render(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment