RE: [PEAR] QuickForm + ITDynamic renderer: problem with required radio button
| From: | Hollenbeck, Dan | Date: | Fri, 07 Mar 2008 15:07:04 +0000 |
| Subject: | RE: [PEAR] QuickForm + ITDynamic renderer: problem with required radio button | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-28613@lists.php.net to get a copy of this message | ||
Hi Cesare,
I don't use the radio element, but rather use the altselect which produces radio buttons.
Try something like this:
$radio_options = array('0'=>'I like QuickForm', '1'=>'I
love QuickForm');
$element =& $form->addElement('altselect', 'field_name', 'Label
Options', $radio_options);
$element->setDelimiter('');
$form->addRule('field_name', 'Please select an option', 'required',
null, 'client');
This would would work fine with your HTML template and you will only get one one error when the user
does not select a radio option.
Also, you should consider changing your QuickForm renender so that the required note is added
automatically to your quickform label so you don't need to add it via your HTML template.
Thanks, Dan
-----Original Message-----
From: Cesare D'Amico [mailto:cesare@ngi.it]
Sent: Friday, March 07, 2008 8:12 AM
To: PEAR general list
Subject: [PEAR] QuickForm + ITDynamic renderer: problem with required radio button
Hello,
I'd need a hint using the ITDynamic renderer; I add a radio group with two
$f->addElement('radio', 'name', ...) (with the same name, and a label only in
the first addElement), then set a "required" rule on it; it shows like this:
* label1 ( ) option1
* ( ) option2
If the user doesn't check any option and submits the form, the error about the missing check is
displayed under each option:
* label1 ( ) option1
this field is required
* ( ) option2
this field is required
This is the HTML template:
<!-- BEGIN qf_radio -->
<tr>
<td class="tab_standard">
<!-- BEGIN qf_element_required --><span
style="color:#F00;">*</span>
{qf_label}
</td>
<td class="tab_standard">
{qf_element}<br />
</td>
</tr>
<!-- END qf_radio -->
Is it possible to put the "required" sign (*) and the error near only one of the options?
I'd like the "*" near the first, and the error under the second option... am I asking
for too much? ;)
Thanks, ciao
Cesare
--
Cesare D'Amico | Gruppo Volta
Area tecnica | Web & Mkt Solutions
Tel: 045 21 000 84 | Via Leida 8 - Verona
Fax: 045 21 000 85 | http://www.gruppovolta.it
--
PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php