HosipLan

Untitled

Aug 11th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public function createComponentBuyItemForm()
  2.     {
  3.         dump('creating BuyItemForm');
  4.  
  5.         $presenter = $this;
  6.             return new \Nette\Application\UI\Multiplier(function ($itemId) use ($presenter) {
  7.                     $form = new Form();
  8.  
  9.                     $form->addText('quantity')
  10.                 ->addRule(Form::FILLED, "Počet kusů musí být vyplněn!")
  11.                 ->addRule(Form::INTEGER)
  12.                 ->setDefaultValue(1);
  13.  
  14.             $form->addSubmit('save', 'Přidat do košíku');
  15.             $form->onSuccess[] = callback($presenter, 'buyItemFormSubmited');
  16.             $form->onError[] = function ($form) { dump($form->values); exit; };
  17.  
  18.             dump('creating form #' . $itemId);
  19.             dump($presenter->context->httpRequest);
  20.  
  21.             return $form;
  22.         });
  23.     }
  24.  
  25.     public function buyItemFormSubmited($form)
  26.     {
  27.         $id = $form->name;
  28.         $quantity = $form->values->quantity;
  29.  
  30.         dump($id, $quantity); exit;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment