Advertisement
Guest User

Untitled

a guest
Jan 14th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?
  2.  
  3. use Nette\Forms\Form;
  4. use Tracy\Debugger;
  5. use Tracy\Dumper;
  6. use Nette\Utils\Html;
  7.  
  8. //Debugger::enable();
  9. //
  10. //
  11. //
  12. print_r($_POST);
  13.  
  14.  
  15. $form = new Form;
  16. $form->action='?1';
  17. $form->getElementPrototype()->novalidate = "novalidate";
  18. $cont = $form->addContainer('first');
  19.  
  20. $cont->addText('name', 'Your name:')
  21.     ->setRequired('Enter your name');
  22.  
  23. $cont->addHidden('a', '1')->setValue(1);
  24. $cont->addSubmit('submit', 'Send');
  25.  
  26.  
  27.  
  28.  
  29. $form2 = new Form;
  30. $form2->action='?2';
  31. $form2->getElementPrototype()->novalidate = "novalidate";
  32. $cont = $form2->addContainer('second');
  33.  
  34. $cont->addText('name', 'Your name:')
  35.     ->setRequired('Enter your name');
  36.  
  37. $cont->addHidden('b', '1')->setValue(1);
  38. $cont->addSubmit('submit', 'Send');
  39.  
  40.  
  41.  
  42. if ($form->isSubmitted() && $form->isSuccess()) {
  43.     echo '<h2>Form was submitted and successfully validated</h2>';
  44.     Dumper::dump($form->getValues(), [Dumper::COLLAPSE => FALSE]);
  45.    
  46. }
  47.  
  48.  
  49. if ($form2->isSubmitted() && $form2->isSuccess()) {
  50.     echo '<h2>Form2 was submitted and successfully validated</h2>';
  51.     Dumper::dump($form2->getValues(), [Dumper::COLLAPSE => FALSE]);
  52.    
  53. }
  54.  
  55.  
  56. ?>
  57. <!DOCTYPE html>
  58. <meta charset="utf-8">
  59. <title>Nette Forms basic example</title>
  60. <link rel="stylesheet" media="screen" href="assets/style.css" />
  61. <script src="https://nette.github.io/resources/js/netteForms.js"></script>
  62.  
  63. <h1>Nette Forms basic example</h1>
  64.  
  65. <?php echo $form ?>
  66. <hr />
  67. <?php echo $form2 ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement