Re: Quickform issues
| From: | Bertrand Mansion | Date: | Sun, 02 Feb 2003 18:19:26 +0000 |
| Subject: | Re: Quickform issues | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3559@lists.php.net to get a copy of this message | ||
<john.f.kline@att.net> wrote :
> Bertrand,
>
> I need to have the following functionality supported in Quickforms 2.1.5:
>
> 1) Having a group of radio buttons with no default value set but with a
> required rule set. For example, a 'yes' or 'no' question or a mandatory
> quality question like: Rate PHP: () superior () average () unacceptable.. I
> do not want to start with a default value BUT I want to require that a radio
> button is selected.
>
> The following code sniblet does not work:
> $radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes',
> 'Y');
> $radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No',
> 'N');
> $form->addElementGroup($radio, 'Yes/No:', 'iradYesNo');
> $form->addGroupRule('iradYesNo', "question is required.",
> 'required','',0); //
> regardless of '1' or '0')
>
>
> One thing I do notice is that a warning is thrown on QuickForm.php line 1563
> because this radio group is a single value and NOT an array. I can not find
> in the code where the decision is made that checkboxes are stored in arrays
> and radios as single values? Any hints?
>
>
> 2) An alternative to the above would be having a rule for checkboxes such
> that one and only one box is selected. Can this be done? It does not appear
> to work.
>
>
>
> Thank you.
>
> Jack Kline
>
>
> PS. I need a solution very soon as I plan on delivering something for a
> client asap. THANKS!
Hi Jack,
Sorry for the time it took, but this is now fixed in CVS.
If you use radio buttons and want at least one to be checked use this rule:
$form->addGroupRule('myRadios', 'Please check one', 'required',
null, 1);
The final 1 parameter says you want at least one to be checked.
Good luck,
Bertrand Mansion
Mamasam