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: 100%;
  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: 100%;
  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.     list-style: none;
  47.     margin: 0;
  48.     clear: both;
  49. }
  50. form label {
  51.     margin: 0 0 0 5px;
  52. }
  53. form label.element {
  54.     display: block;
  55.     float: left;
  56.     width: 150px;
  57.     padding: 0;
  58.     margin: 5px 0 0 0;
  59.     font-weight: bold;
  60.     text-align: right;
  61. }
  62. form input, form textarea, form select {
  63.     width: auto;
  64. }
  65. form textarea {
  66.     overflow: auto;
  67. }
  68. form br {
  69.     clear: left;
  70. }
  71. form div.element {
  72.     display: inline;
  73.     float: left;
  74.     margin: 5px 0 0 10px;
  75.     padding: 0;
  76. }
  77. form li.reqnote {
  78.     font-size: 80%; 
  79.     margin: 5px 0 0 10px;
  80. }
  81. form span.error, form span.required {
  82.     color: red;
  83. }
  84. form div.error {
  85.     border: 1px solid red;
  86.     padding: 5px;
  87. }
  88.     </style>
  89.     <title>HTML_QuickForm_Renderer_Tableless example</title>
  90.   </head>
  91.   <body>
  92. <?php
  93.  
  94. require_once 'HTML/QuickForm.php';
  95. require_once 'HTML/QuickForm/Renderer/Tableless.php';
  96.  
  97. $form = new HTML_QuickForm('contact'nullnullnullnulltrue);
  98. $form->removeAttribute('name');  // for XHTML validity
  99.  
  100. $form->addElement('header''header''Tableless renderer example');
  101.  
  102. $form->addElement('text''name''Your name:'array('style' => 'width: 300px;'));
  103. $form->addElement('text''email''Your email:'array('style' => 'width: 300px;'));
  104. $form->addElement('text''emptylabel'''array('style' => 'width: 300px;'));
  105. $form->addElement('text'null'Element without name:'array('style' => 'width: 300px;'));
  106. $form->addElement('text''''Element with empty name:'array('style' => 'width: 300px;'));
  107. $form->addElement('text''subject''Your subject:'array('style' => 'width: 300px;'));
  108. $form->addElement('checkbox''single''Checkbox example:'' Check me if you agree to receive spam ;-)');
  109.  
  110. $form->addElement('header''header2''Some groups');
  111.  
  112. $radio = array();
  113. $radio[&HTML_QuickForm::createElement('radio''country'null'France''france');
  114. $radio[&HTML_QuickForm::createElement('radio''country'null'Germany''germany');
  115. $radio[&HTML_QuickForm::createElement('radio''country'null'Austria''austria');
  116. $radio[&HTML_QuickForm::createElement('radio''country'null'Other''other');
  117. $form->addGroup($radio'group1''Choose a country:'' ');
  118.  
  119. $form->addElement('date''date''Date:'array('format' => 'Y-m-d H:i''optionIncrement' => array('i' => 5)));
  120.  
  121. $checkbox = array();
  122. $checkbox[&HTML_QuickForm::createElement('checkbox''A1'null'France');
  123. $checkbox[&HTML_QuickForm::createElement('checkbox''B1'null'Germany');
  124. $checkbox[&HTML_QuickForm::createElement('checkbox''C1'null'Austria');
  125. $checkbox[&HTML_QuickForm::createElement('checkbox''D1'null'Other');
  126. $form->addGroup($checkbox'group2''Choose a country:'' ');
  127.  
  128. $checkbox = array();
  129. $checkbox[&HTML_QuickForm::createElement('checkbox''A2'null'France');
  130. $checkbox[&HTML_QuickForm::createElement('checkbox''B2'null'Germany');
  131. $checkbox[&HTML_QuickForm::createElement('checkbox''C2'null'Austria');
  132. $checkbox[&HTML_QuickForm::createElement('checkbox''D2'null'Other');
  133. $form->addGroup($checkbox'group3''Choose a country:''<br />');
  134.  
  135. $form->addElement('header''header3''The third fieldset');
  136.  
  137. $main[0'Pop';
  138. $main[1'Rock';
  139. $main[2'Classical';
  140.  
  141. $secondary[0][0'Belle &amp; Sebastian';
  142. $secondary[0][1'Elliot Smith';
  143. $secondary[0][2'Beck';
  144. $secondary[1][3'Noir Desir';
  145. $secondary[1][4'Violent Femmes';
  146. $secondary[2][5'Wagner';
  147. $secondary[2][6'Mozart';
  148. $secondary[2][7'Beethoven';
  149.  
  150. $select =$form->addElement('hierselect''music''Please select:');
  151. $select->setOptions(array($main$secondary));
  152.  
  153. $form->addElement('textarea''message''Your message:'array('style' => 'width: 300px;''cols' => 50'rows' => '7'));
  154. $form->addElement('submit''submit''Submit');
  155.  
  156. $form->addElement('hidden''hidden1''x');
  157. $form->addElement('hidden''hidden2''y');
  158. $form->addElement('hidden''hidden3''z');
  159.  
  160. $form->addRule('name''Please enter your name''required'null'client');
  161. $form->addRule('email''Please enter your email address.''required'null'client');
  162. $form->addRule('email''Please enter a valid email address.''email'null'client');
  163. $form->addRule('subject''Please enter a subject.''required'null'client');
  164. $form->addRule('message''Please enter a message.''required'null'client');
  165.  
  166. if ($form->isSubmitted(&& $form->validate()) {
  167.   $data $form->exportValues();
  168.   // do something with $data
  169.   echo "<p>Thank you</p>\n";
  170. }
  171. else {
  172.   $renderer =new HTML_QuickForm_Renderer_Tableless();
  173.   $renderer->addStopFieldsetElements('submit');
  174.   $form->accept($renderer);
  175.   echo $renderer->toHtml();
  176. }
  177.  
  178. ?>
  179.   </body>
  180. </html>

Documentation generated on Mon, 11 Mar 2019 15:44:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.