RE: [PEAR] QF - conditional elements requiring conditional rules!
| From: | Donald Lobo | Date: | Thu, 15 Apr 2004 15:45:16 +0000 |
| Subject: | RE: [PEAR] QF - conditional elements requiring conditional rules! | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-11865@lists.php.net to get a copy of this message | ||
u could either use a FormRule or combine the two elements as a group and use
a Rule on that group (however u have less control on the group display)
in your case i suspect a FormRule works best :)
lobo
> -----Original Message-----
> From: Tommy Ipsen [mailto:tipsen@imada.sdu.dk]
> Sent: Thursday, April 15, 2004 8:43 AM
> To: pear-general@lists.php.net
> Subject: [PEAR] QF - conditional elements requiring conditional rules!
>
>
> Hi
>
> I have the following form fields generated by QuickForm:
>
> <select
> onchange="this.form.url_manual.disabled=this.selectedIndex!=0;
> " name="url_automatic">
> <option value="none">Ekstern side</option>
> <option value="url1">Link to URL1</option>
> <option value="url2">Link to URL2</option>
> <option value="url3">Link to URL3</option>
> </select>
> <input value="Type URL"
> onchange="this.form.url_automatic.disabled=(this.value!='' &&
> this.value!=this.defaultValue);" name="url_manual" type="text" />
>
> These two fields are mutually exclusive meaning that either
> you choose an option from the drop-down
> menu or you type in a value in the text field.
>
> Now I want to add a crude validation to the text field
> helping the user to type in a correct URL and
> I've reached the following:
>
> $form->registerRule('url', 'regex',
> '/(^(ldap|http|https|ftp):\/\/(([a-z0-9\-\.]+\.+[a-z]{2,6})|([
> 0-9]{1,3}\.){4})(\]?)$)/');
>
> But the problem is that an URL is ONLY required IF the
> first/default option from the drop-down menu
> is active - if any other element is chosen, the text field is
> disabled and the rule shouldn't trigger!
>
> How can I accomplish this behaviour using QuickForm?
>
> Regards,
>
> Tommy Ipsen
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>