Kcko
1/4/2016 - 3:39 PM

Nette - multiplier.php

{foreach ... as $row}
        {form order-$row}
              {input count}
              {input send}
          {/form}
{/foreach}
<?php
	
protected function createComponentOrder()
	{
		$that = $this;
		return new Multiplier(function ($itemId) use($that) {
			$form = new Form;
			$form->getElementPrototype()->class[] = "ajax";
			$form->addText('count', 'Počet zboží:')
				->addRule($form::FILLED,'Zadejte prosím počet kusů.')
				->addRule($form::INTEGER,'Počet kusů musí být číslo.');
			$form->addHidden('itemId', $itemId);
			$form->addSubmit('send', 'Přidat');
			$form->onSuccess[] = array($that,'saveOrder');
			$form->setDefaults(array('count'=>1));
			return $form;
		});
	}