{define form $formName}
	<form n:name=$formName>
	<ul class=error n:ifcontent>
		<li n:foreach="$form->ownErrors as $error">{$error}</li>
	</ul>
	<table>
	<tr n:foreach="$form->controls as $input"
		n:if="!$input->getOption(rendered) && $input->getOption(type) !== hidden"
		n:class="$input->required ? required">
		<th>{label $input}</th>
		<td>{input $input} <span class=error n:ifcontent>{$input->error}</span></td>
	</tr>
	</table>
	</form>
{/define}
{* for Bootstrap v3 *}
{define bootstrap-form $formName}
	<form n:name=$formName class=form-horizontal>
	<ul class=error n:ifcontent>
		<li n:foreach="$form->ownErrors as $error">{$error}</li>
	</ul>
	<div n:foreach="$form->controls as $name => $input"
		n:if="!$input->getOption(rendered) && $input->getOption(type) !== hidden"
		n:class="form-group, $input->required ? required, $input->error ? has-error">
		<div class="col-sm-2 control-label">{label $input}</div>
		<div class="col-sm-10">
			{if $input->getOption(type) in [text, select, textarea]}
				{input $input class => form-control}
			{elseif $input->getOption(type) === button}
				{input $input class => "btn btn-default"}
			{elseif $input->getOption(type) === checkbox}
				<div class="checkbox">{input $input}</div>
			{elseif $input->getOption(type) === radio}
				<div class="radio">{input $input}</div>
			{else}
				{input $input}
			{/if}
			<span class=help-block n:ifcontent>{$input->error ?: $input->getOption(description)}</span>
		</div>
	</div>
	</form>
{/define}
                                 
                                 
                        
CREATE TABLE shop (
    article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
    dealer  CHAR(20)                 DEFAULT ''     NOT NULL,
    price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL,
    PRIMARY KEY(article, dealer));
INSERT INTO shop VALUES
    (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),
    (3,'C',1.69),(3,'D',1.25),(4,'D',19.95);
    
    
    
+---------+--------+-------+
| article | dealer | price |
+---------+--------+-------+
|    0001 | A      |  3.45 |
|    0001 | B      |  3.99 |
|    0002 | A      | 10.99 |
|    0003 | B      |  1.45 |
|    0003 | C      |  1.69 |
|    0003 | D      |  1.25 |
|    0004 | D      | 19.95 |
+---------+--------+-------+
                                 
                                 
                        <div class="col-12">
    {!$form['agreement']->getOneLabel('basic')->startTag()}
        {$form['agreement']->getOneControl('basic')}
        {!_'Souhlasím zpracování'}
    {!$form['agreement']->getOneLabel('basic')->endTag()}
</div>
<div class="cl"></div>
<div class="h15"></div>
<div class="col-12">
    {!$form['agreement']->getOneLabel('full')->startTag()}
        {$form['agreement']->getOneControl('full')}
        {!_'Nesouhlasím zpracování'}
     {!$form['agreement']->getOneLabel('full')->endTag()}
</div>
                                 
                                 
                        <?php
$con->table('table_name')->where('name LIKE ?',new \Nette\Database\SqlLiteral($con->getSupplementalDriver()->formatLike('John Doe', 0)));
$con->table('table_name')->get(1)->update(array('updated_at'=>new \Nette\Database\SqlLiteral('NOW()')))
// SET quantity = quantity + 1
array('quantity' => new \Nette\Database\SqlLiteral('quantity + 1'))
                                 
                                 
                        <?php
$component = $this->context->createInstance('\\App\\Components\\'. $ucname );
if($component)
					$this->context->callInjects($component);
					
// $container je systémový kontejner, např. $presenter->context
$httpRequest = $container->getService('httpRequest');
// nebo zkráceně:
$httpRequest = $container->httpRequest;
                                 
                                 
                        <?php
$pathToFile = $this->context->expand("%wwwDir%/files/soubor.pdf");
                                 
                                 
                        {foreach $polls as $id => $poll}
    <h2>Anketa {$poll->name}</h2>
    {control poll-$id}
{/foreach}
                                 
                                 
                        <?php
namespace App\FrontModule\Components;
use Nette\Application\UI,
	Nette,
	Nette\Mail\Message,
	Nette\Mail\SendmailMailer,
	App,
	CardBook;
interface IContactUsFormFactory
{
	/** @return ContactUsForm */
	public function create ();
}
class ContactUsForm extends UI\Control 
{
	protected $userModel;
	protected $mailer;
	protected $messageFactory;
	
	/** @persistent */
	public $view;
	public function __construct (App\Model\User $user, Nette\Mail\IMailer $mailer, App\FrontModule\Factory\MessageFactory $messageFactory)
	{
		parent::__construct();
		$this->userModel = $user;
		$this->mailer    = $mailer;
		$this->messageFactory   = $messageFactory;
	}
	public function render() 
	{
		
		if (!$this->view)
			$this->template->setFile(__DIR__ . '/../templates/components/ContactUsForm/form.latte');
		else
			$this->template->setFile(__DIR__ . '/../templates/components/ContactUsForm/'.$this->view.'.latte');
		
		$this->template->render();
	}
	public function createComponentForm()
	{
		$form = new UI\Form;
		$form->addText("name", "Vaše jméno")
			 ->addRule($form::FILLED, "Vyplňte prosím jméno");
		
		$form->addText("email", "E-mail")
			 ->addRule($form::FILLED, "Vyplňte prosím email")
			 ->addRule($form::EMAIL, "Email není ve správném formátu");
		
		$form->addTextArea("message", "Vaše zpráva")
		     ->addRule($form::FILLED, "Vyplňte prosím Váš dotaz");
		$form->addSubmit("send", "Odeslat");
		$form->onSuccess[] = array($this, 'submitted');
		return $form;
	}
	public function submitted($form)
	{
		$values = $form->getValues();
	
	    $template = $this->createTemplate();
	    $template->setFile(__DIR__ . '/../templates/emails/contactus.latte');
		$template->title  = 'Napište nám';
		$template->values = $values;
	
		$mail = $this->messageFactory->create();
	
		//$mail = new Message;
		$mail->setFrom($values->email)
		     ->addTo(CardBook\Settings::ADMIN_EMAIL)
		     ->setSubject('Cardbook - napište nám')
		     ->setHtmlBody($template);
		
		$this->mailer->send($mail);
		// $mailer = new SendmailMailer;  1)
		// $mailer = new Nette\Mail\SmtpMailer(array(  2)
		// 		'host'     => 'smtp.savana.cz',
		// 		'username' => 'podpora@cardbook.cz',
		// 		'password' => 'uL$g4GHl6AR'
		// ));
		// $mailer->send($mail);
		// 3)
		// 
		
		//  arguments: [..., ..., %foo%, %bar%] #ano, opravdu dvojtecky
		// nebo:
		// arguments: [foo: %foo%, bar: %bar%]
		// nebo:
		// arguments: [2: %foo%, 3: %bar%]
 
		
        if ($this->presenter->isAjax()) 
        {
           	$this->view = 'save';
    		$this->redrawControl('contactUsForm');
     
        }
        else
        {
        	$this->redirect("this", array('view' => 'save'));
        }
		
	}
}
                                 
                                 
                        nette:
	latte:
		macros: [Img\ImgMacro]
services:
	imageStorage: Img\ImageStorage(%tempDir%)
	imagePipe: Img\ImagePipe(%wwwDir%)