<?php
require_once('HTML/QuickForm.php');
require_once('HTML/QuickForm/Renderer/Default.php');

$template =
'<tr>
    <td align="right" valign="top">
        <!-- BEGIN required --><font color="red">*</font><!-- END required -->
        <b>{label}</b>
    </td>
    <td nowrap="nowrap" valign="top" align="left">
        {element}
        <!-- BEGIN error --><br/><font color="red">{error}</font><br/><!-- END error -->
        <!-- BEGIN label_0 --><br/><font size="-1">{label_0}</font><!-- END label_0 -->
    </td>
</tr>';

$renderer = new HTML_QuickForm_Renderer_Default();
$renderer->setElementTemplate($template);

// Create the form, and add a header to it.
$form = new HTML_QuickForm('labels_example', 'post');
$form->addHeader('QuickForm Labels Example');

// Do the magic! Just pass your label to the element as an array!
$form->addElement('text', 'name', array('Name', 'The name that you would like to enter in this element.'));
$form->addElement('checkbox', 'check', array('Check Me!', 'If you check this box, it will have tick in it.'));

// More boring stuff.
$form->addElement('submit', null, 'Submit');

if ($form->validate()) {
    $form->freeze();
}

$form->accept(&$renderer);
echo $renderer->toHtml();
?>
