Re: How to use HTML_Table with HTML_QuickForm
| From: | Mark Wiesemann | Date: | Wed, 17 Aug 2005 07:53:34 +0000 |
| Subject: | Re: How to use HTML_Table with HTML_QuickForm | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20447@lists.php.net to get a copy of this message | ||
Hi Joe,
don't know if I got your problem right but I try it anyway:
> <?php
> require_once "HTML/QuickForm.php";
> require_once "HTML/Table.php";
Add here:
require_once 'HTML/QuickForm/Renderer/QuickHtml.php';
> $tableForm = new HTML_QuickForm('tableForm', 'POST');
Add here your form elements, e.g. like this:
$tableForm->addElement('checkbox', 'st["OG012"]');
...
And then add the following two lines of code:
$renderer =& new HTML_QuickForm_Renderer_QuickHtml();
$tableForm->accept($renderer);
> $tableStyle = "border=1 width=450";
> $table = new HTML_Table($tableStyle);
> $table->setAutoGrow(true);
> $table->setCaption('Example');
> $rowHeaders = array('checkbox', 'id', 'name');
> $table->addRow($rowHeaders);
> $table->setRowAttributes(0, "bgcolor=#99CCCC align=center");
>
> $table->addRow(array($tableForm->addElement('checkbox',
> 'st["OG012"]'),
> 'OG012', 'Joe'));
Instead of
$tableForm->addElement(...)
use now here
$renderer->elementToHtml('st["OG012"]')
[...]
> $tableForm->addElement('submit', 'submit', 'Submit');
Use here $table->addRow(array($renderer->elementToHtml('submit')));
[...]
> else
> {
> $table->display();
And finally replace this with:
echo $renderer->toHtml($table->toHtml());
> }
> ?>
Untested, but that's the way it should work. More about the renderers
can be found in the manual.
Mark