Guest User

Untitled

a guest
May 28th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment