Re: HTML_QuickForm addGroupRule question
| From: | Bertrand Mansion | Date: | Sat, 14 Dec 2002 10:27:18 +0000 |
| Subject: | Re: HTML_QuickForm addGroupRule question | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-2980@lists.php.net to get a copy of this message | ||
<culley@ml1.net> wrote :
> So given something like this:
>
> //=========================================
> $sql = "select id_col, desc_col from table1";
> $data = $dbh->getAssoc($sql);
> foreach($data as $k => $v) {
> $checkbox[] = &HTML_QuickForm::createElement('checkbox', $k, null, $v);
> }
>
> $form->addElementGroup($checkbox, 'Categories:', 'categories',
> '<br />');
> $form->addElement('submit', 'save_button', 'Save');
> //TODO: this doesnt work
> $form->addGroupRule('categories', 'You must select at least one
> category.',
> 'required');
If you need only one check box to be set at least, you have to specify it
otherwise QuickForm will require all checkboxes to be checked.
$form->addGroupRule('categories', 'You must select at least one category.',
'required', '', 1);
> //=========================================
>
> is it possible to use addGroupRule to make at sure at least one item is
> checked?
Have a look at the examples, one of them is about group rules and shows
almost all possibilities of group rules.
BTW, did you tried your previous code with the new versions from CVS ?
http://cvs.php.net in pear/HTML/ directory
Bertrand Mansion
Mamasam