Re: Re: How to use HTML_Table with HTML_QuickForm

From: Date: Thu, 18 Aug 2005 01:05:21 +0000
Subject: Re: Re: How to use HTML_Table with HTML_QuickForm
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20455@lists.php.net to get a copy of this message
On 8/17/05, Mark Wiesemann wrote: > Hi Joe, Hi Mark, > 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. Cool! Thank you very much for your help, it works great :-) By the way, if I use your way, how do I know which checkbox is enabled Would you tell me? Thanks again. > > Mark Regards, Joe.

« previous php.pear.general (#20455) next »