Formagic
[ class tree: Formagic ] [ index: Formagic ] [ all elements ]

Source for file index.php

Documentation is available at index.php

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3.        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
  5. <head>
  6.     <title>Formagic Test</title>
  7.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8.     <meta http-equiv="Content-Script-Type" content="text/javascript" />
  9. </head>
  10. <body>
  11. <?php
  12. $old error_reporting(E_ALL);
  13. require_once 'Benchmark/Timer.php';
  14.  
  15. $bench new Benchmark_Timer();
  16. $bench->start();
  17.  
  18. include('formagic.php');
  19.  
  20. $bench->setMarker('formagic load');
  21.  
  22. $def array('ipName1' => 'defaultVal',
  23.              'subitem' => 'default value for subitem',
  24.              'pass' => 'grml');
  25. // $saves = array('ipName1');
  26.  
  27. $form new formagic('test'array('method' => 'get'));
  28. $form->setDefaultValues($def);
  29.  
  30. // page controller
  31. $pc $form->addItem('pageController''bb');
  32.  
  33. // page 1
  34. $p1 $pc->addItem('page''page1');
  35. $p1->addItem('input','subitem',array('label'=>'sub1''blocked' => true));
  36. $data array('asdf' => 'Val1''Val2''Val3');
  37. $p1->addItem('select','select1',
  38.                 array('label'=>'sub2',
  39.                       'default'=>'1',
  40.                       'data' => $data,
  41.                       'attributes'=>array('style'=>'background-color:#ffff00',
  42.                                           'onchange' => 'submit()')
  43.                       )
  44.              );
  45. $p1i1 $p1->addItem('input','page1Input2',array('default'=>'Page1''label' => 'dummy'));
  46. $p1i1->addRule('numeric');
  47. // $p1i1->addRule('length', null, array('min' => 10, 'max' => 11));
  48.  
  49.  
  50. $data array(3=> 'Radio1'84 => 'Radio2'564 => 'Radio3');
  51. $p1->addItem('radio','radio1'array('label'=>'gaga',
  52.                                     // 'default'=> 84,
  53.                                     'addEmpty' => true,
  54.                                     'data' => $data,
  55.                                     // 'attributes'=>array('onChange' => 'submit()')
  56.                                )
  57.              );
  58. $p1->addItem('pageSwitch''page2'array('label' => 'To Page 2'));
  59.  
  60.  
  61. // page 2
  62. $p2 $pc->addItem('page''page2');
  63. $p2->addItem('input','page2Item1',array('default'=>'Page2, Item1''label' => 'dummy'));
  64. $p2->addItem('input','page2Item2',array('default'=>'Page2, Item2''label' => 'dummy2'));
  65. $p2->addItem('pageSwitch''page1'array('label' => 'To Page 1'));
  66.  
  67. // pageless items
  68. $ip1 $form->addItem('input','ipName1',array('label'=>'test1''default' => 'fad'));
  69. $ip1->addRule('mandatory');
  70. $ip1->setAttributes(array('class'=>'grml','style'=>'color:#00aa00'));
  71.  
  72. $ip2 $form->addItem('hidden','ipName2',array('label'=>'test1''default' => 'hideme'));
  73. $pw1 $form->addItem('password','pass',array('label'=>'geheim:'));
  74. $pw2 $form->addItem('password','passRepeat',array('label'=>'geheim:'));
  75. $pw1->addRule('equal'null$pw2);
  76. // $pw1->addRule('mandatory');
  77. $form->addItem('checkbox','check1',array('label'=>'check1check2'));
  78. $form->addItem('submit','go',array('label'=>'los!''attributes' => array('style'=>'color: #ff0000')));
  79.  
  80.  
  81.  
  82. // $form->block();
  83.  
  84. echo $form;
  85.  
  86. if ($form->validate()) {
  87.     print_r($_REQUEST);
  88.     echo "submitted and ok<br />";
  89.     $form->block();
  90. //    print_r($form->getValues());
  91. }
  92. $bench->setMarker('build items');
  93. echo $form->fetch();
  94. $bench->setMarker('fetch');
  95.  
  96. print_r($form->getValues());
  97.  
  98. // some info stuff
  99. echo "<br /><br /><pre>" memory_get_peak_usage(1024 print_r(get_included_files(),true"</pre>";
  100. $bench->display();
  101.  
  102. ?>
  103.  
  104. </body>
  105. </html>

Documentation generated on Thu, 23 Aug 2007 00:29:41 +0200 by phpDocumentor 1.4.0