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

Source for file contact.php

Documentation is available at contact.php

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  2.     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3. <html>
  4.   <head>
  5.     <style type="text/css">
  6. /* this style is used only for this example to make it look better */
  7. /* only the second block (it's the same as in data/stylesheet.css) is relevant */
  8. body {
  9.     margin-left: 10px;
  10.     font-family: Arial,sans-serif;
  11.     font-size: small;
  12. }
  13.     </style>
  14.     <style type="text/css">
  15. form {
  16.     margin: 0;
  17.     padding: 0;
  18.     min-width: 500px;
  19.     max-width: 600px;
  20.     width: 560px;
  21. }
  22. form fieldset {
  23.     clear: both;
  24.     float: left;
  25.     border: 0;
  26.     margin: 0;
  27.     width: 560px;
  28. }
  29. form fieldset.hidden {
  30.     border: 0;
  31. }
  32. form fieldset legend {
  33.     white-space: nowrap;
  34.     background-color: #CCCCCC;
  35.     font-weight: bold;
  36.     width: 560px;
  37.     padding: 1px;
  38.     display: block;
  39. }
  40. form fieldset ol {
  41.     margin: 0;
  42.     padding: 0;
  43. }
  44. form fieldset li {
  45.     display: block;
  46.     height: 1px;
  47.     list-style: none;
  48.     margin: 0;
  49.     clear: both;
  50. }
  51. form label {
  52.     margin: 0 0 0 5px;
  53. }
  54. form label.element {
  55.     display: block;
  56.     float: left;
  57.     width: 150px;
  58.     padding: 0;
  59.     margin: 5px 0 0 0;
  60.     font-weight: bold;
  61.     text-align: right;
  62. }
  63. form input, form textarea, form select {
  64.     width: auto;
  65. }
  66. form textarea {
  67.     overflow: auto;
  68. }
  69. form br {
  70.     clear: left;
  71. }
  72. form div.element {
  73.     display: inline;
  74.     float: left;
  75.     margin: 5px 0 0 10px;
  76.     padding: 0;
  77. }
  78. form li.reqnote {
  79.     font-size: 80%; 
  80.     margin: 5px 0 0 10px;
  81. }
  82. form span.error, form span.required {
  83.     color: red;
  84. }
  85. form div.error {
  86.     border: 1px solid red;
  87.     padding: 5px;
  88. }
  89.     </style>
  90.     <title>HTML_QuickForm_Renderer_Tableless example</title>
  91.   </head>
  92.   <body>
  93. <?php
  94.  
  95. require_once 'HTML/QuickForm.php';
  96. require_once 'HTML/QuickForm/Renderer/Tableless.php';
  97.  
  98. $form = new HTML_QuickForm('contact'nullnullnullnulltrue);
  99. $form->removeAttribute('name');  // for XHTML validity
  100.  
  101. $form->addElement('header''header''Tableless renderer example');
  102.  
  103. $form->addElement('text''name''Your name:'array('style' => 'width: 300px;'));
  104. $form->addElement('text''email''Your email:'array('style' => 'width: 300px;'));
  105. $form->addElement('text''emptylabel'''array('style' => 'width: 300px;'));
  106. $form->addElement('text'null'Element without name:'array('style' => 'width: 300px;'));
  107. $form->addElement('text''''Element with empty name:'array('style' => 'width: 300px;'));
  108. $form->addElement('text''subject''Your subject:'array('style' => 'width: 300px;'));
  109. $form->addElement('checkbox''single''Checkbox example:'' Check me if you agree to receive spam ;-)');
  110.  
  111. $form->addElement('header''header2''Some groups');
  112.  
  113. $radio = array();
  114. $radio[&HTML_QuickForm::createElement('radio''country'null'France''france');
  115. $radio[&HTML_QuickForm::createElement('radio''country'null'Germany''germany');
  116. $radio[&HTML_QuickForm::createElement('radio''country'null'Austria''austria');
  117. $radio[&HTML_QuickForm::createElement('radio''country'null'Other''other');
  118. $form->addGroup($radio'group1''Choose a country:'' ');
  119.  
  120. $form->addElement('date''date''Date:'array('format' => 'Y-m-d H:i''optionIncrement' => array('i' => 5)));
  121.  
  122. $checkbox = array();
  123. $checkbox[&HTML_QuickForm::createElement('checkbox''A1'null'France');
  124. $checkbox[&HTML_QuickForm::createElement('checkbox''B1'null'Germany');
  125. $checkbox[&HTML_QuickForm::createElement('checkbox''C1'null'Austria');
  126. $checkbox[&HTML_QuickForm::createElement('checkbox''D1'null'Other');
  127. $form->addGroup($checkbox'group2''Choose a country:'' ');
  128.  
  129. $checkbox = array();
  130. $checkbox[&HTML_QuickForm::createElement('checkbox''A2'null'France');
  131. $checkbox[&HTML_QuickForm::createElement('checkbox''B2'null'Germany');
  132. $checkbox[&HTML_QuickForm::createElement('checkbox''C2'null'Austria');
  133. $checkbox[&HTML_QuickForm::createElement('checkbox''D2'null'Other');
  134. $form->addGroup($checkbox'group3''Choose a country:''<br />');
  135.  
  136. $form->addElement('header''header3''The third fieldset');
  137.  
  138. $main[0'Pop';
  139. $main[1'Rock';
  140. $main[2'Classical';
  141.  
  142. $secondary[0][0'Belle &amp; Sebastian';
  143. $secondary[0][1'Elliot Smith';
  144. $secondary[0][2'Beck';
  145. $secondary[1][3'Noir Desir';
  146. $secondary[1][4'Violent Femmes';
  147. $secondary[2][5'Wagner';
  148. $secondary[2][6'Mozart';
  149. $secondary[2][7'Beethoven';
  150.  
  151. $select =$form->addElement('hierselect''music''Please select:');
  152. $select->setOptions(array($main$secondary));
  153.  
  154. $form->addElement('textarea''message''Your message:'array('style' => 'width: 300px;''cols' => 50'rows' => '7'));
  155. $form->addElement('submit''submit''Submit');
  156.  
  157. $form->addElement('hidden''hidden1''x');
  158. $form->addElement('hidden''hidden2''y');
  159. $form->addElement('hidden''hidden3''z');
  160.  
  161. $form->addRule('name''Please enter your name''required'null'client');
  162. $form->addRule('email''Please enter your email address.''required'null'client');
  163. $form->addRule('email''Please enter a valid email address.''email'null'client');
  164. $form->addRule('subject''Please enter a subject.''required'null'client');
  165. $form->addRule('message''Please enter a message.''required'null'client');
  166.  
  167. if ($form->isSubmitted(&& $form->validate()) {
  168.   $data $form->exportValues();
  169.   // do something with $data
  170.     echo "<p>Thank you</p>\n";
  171. }
  172. else {
  173.   $renderer =new HTML_QuickForm_Renderer_Tableless();
  174.   $renderer->addStopFieldsetElements('submit');
  175.   $form->accept($renderer);
  176.   echo $renderer->toHtml();
  177. }
  178.  
  179. ?>
  180.   </body>
  181. </html>

Documentation generated on Thu, 09 Nov 2006 16:30:03 -0500 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.