home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / multiple-labels.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  1.4 KB  |  47 lines

  1. <?php
  2. /**
  3.  * Example of usage for QuickForm elements with multiple labels (using Default renderer)
  4.  *
  5.  * @author Jon Wood <jon@jellybob.co.uk>
  6.  *
  7.  * $Id: multiple-labels.php,v 1.1 2004/03/06 12:03:50 avb Exp $ 
  8.  */
  9.  
  10. require_once 'HTML/QuickForm.php';
  11.  
  12. $template =
  13. '<tr>
  14.     <td align="right" valign="top">
  15.         <!-- BEGIN required --><font color="red">*</font><!-- END required -->
  16.         <b>{label}</b>
  17.     </td>
  18.     <td nowrap="nowrap" valign="top" align="left">
  19.         {element}
  20.         <!-- BEGIN error --><br/><font color="red">{error}</font><br/><!-- END error -->
  21.         <!-- BEGIN label_2 --><br/><font size="-1">{label_2}</font><!-- END label_2 -->
  22.     </td>
  23. </tr>';
  24.  
  25. // Create the form, and add a header to it.
  26. $form = new HTML_QuickForm('labels_example', 'post');
  27. $form->addHeader('QuickForm Labels Example');
  28.  
  29. // Do the magic! Just pass your label to the element as an array!
  30. $form->addElement('text', 'name', array('Name', 'The name that you would like to enter in this element.'));
  31. $form->addElement('checkbox', 'check', array('Check Me!', 'If you check this box, it will have tick in it.'));
  32.  
  33. // More boring stuff.
  34. $form->addElement('submit', null, 'Submit');
  35.  
  36. if ($form->validate()) {
  37.     $form->freeze();
  38. }
  39.  
  40. // customize the element template
  41. $renderer =& $form->defaultRenderer();
  42. $renderer->setElementTemplate($template);
  43.  
  44. // output the form
  45. $form->display();
  46. ?>
  47.