Last active
August 29, 2015 13:56
-
-
Save fprochazka/9039061 to your computer and use it in GitHub Desktop.
This file contains 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
{control formProductAdd} |
This file contains 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 | |
/* presenter */ | |
protected function createComponentFormProductAdd(){ | |
return new \FormProductAdd($this->database); | |
} |
This file contains 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
{* vykresli cely form *} | |
{control form} | |
{* vykresli casti formu *} | |
<form n:name="form"> | |
... | |
</form> |
This file contains 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\Form; | |
class FormProductAdd extends Nette\Application\UI\Control | |
{ | |
private $database; | |
public function __construct(Nette\Database\Context $database) | |
{ | |
parent::__construct(); | |
$this->database = $database; | |
} | |
public function render() | |
{ | |
$this->template->setFile(__DIR__ . '/FormProductAdd.latte')->render(); | |
} | |
protected function createComponentForm() | |
{ | |
$form = new Nette\Application\UI\Form; | |
... | |
$form->addSubmit('send', 'Přidat'); | |
$form->onSuccess[] = $this->process; | |
return $form; | |
} | |
public function process($form) | |
{ | |
... | |
$this->flashMessage('Produkt vložen.'); | |
$this->redirect('this'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment