daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest May 28th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. use Nette\Application\AppForm;
  4.  
  5. class TestPresenter extends Nette\Application\Presenter
  6. {
  7.  
  8.     public function renderDefault()
  9.     {
  10.         $this['test']->render();
  11.     }
  12.    
  13.     protected function createComponentTest()
  14.     {
  15.         $form = new AppForm($this, 'test');
  16.        
  17.         $form->addText('txt', 'text')
  18.                 ->addRule(AppForm::INTEGER, 'Not a number')
  19.                 ->addRule(function ($control) {
  20.                     return strlen($control->value) > 3;
  21.                 }, 'Not long enough');
  22.         $form->addSubmit('s', 'send');
  23.        
  24.         $form->onSubmit[] = function ($frm) {
  25.             dump($frm->values);
  26.         };
  27.     }
  28.  
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top