Re: Re: How to use HTML_Table with HTML_QuickForm
| From: | Joe Culler | Date: | Thu, 18 Aug 2005 13:16:49 +0000 |
| Subject: | Re: Re: How to use HTML_Table with HTML_QuickForm | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20463@lists.php.net to get a copy of this message | ||
Mark Wiesemann wrote:
> Joe Culler wrote:
>
> > By the way, if I use your way, how do I know which checkbox is enabled
> > Would you tell me? Thanks again.
>
> After submitting you should get the same results as before. If not, you
> please share (parts of) your code with us.
Here is my code:
<?php
require_once "HTML/QuickForm.php";
require_once "HTML/Table.php";
require_once "HTML/QuickForm/Renderer/QuickHtml.php";
$form = new HTML_QuickForm('form', 'POST');
$form->addElement('text', 'name', 'Input text:');
$form->addElement('submit', 'submit', 'Submit');
$form->addRule('name', 'Please input name', 'required');
if ($form->validate())
{
$tableForm = new HTML_QuickForm('tableForm', 'POST');
$tableForm->addElement('checkbox', 'st[OG012]');
$tableForm->addElement('checkbox', 'st[OG013]');
$tableForm->addElement('submit', 'ssubmit', 'Submit');
$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($renderer->elementToHtml('st[OG012]'),
'OG012', 'Joe'));
$table->addRow(array($renderer->elementToHtml('st[OG013]'),
'OG013', 'Mary'));
$table->addRow(array($renderer->elementToHtml('ssubmit')));
echo $renderer->toHtml($table->toHtml());
$temp = $tableForm->exportValues();
print_r($temp);
//foreach ($temp['st'] as $pkg=>$bool)
// print "{$pkg}\n";
}
else
$form->display();
?>
After submitting the submit button(ssubmit) in the table form,
it will redirect the original page.
If I remove the line:
$form->addRule('name', 'Please input name', 'required');
Then the program runs fine and I know which checkbox is enabled.
Would you tell me how to solve this issue? Thanks in advance.
> Mark
Best regards,
Joe.