Re: QuickForm : problem with a custom rule
| From: | Bertrand Mansion | Date: | Thu, 17 Feb 2005 09:43:53 +0000 |
| Subject: | Re: QuickForm : problem with a custom rule | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-36236@lists.php.net to get a copy of this message | ||
Frederic Poeydomenge wrote:
>Hi folks,
>
>I would like to have your point of vue on a problem with HTML_QuickForm,
>when registering a subclass of HTML_QuickForm_Rule (installed version =
>3.2.4pl1).
>
>The problem is that, even if a file element is not declared as
>"required", the validate() method from the custom class rule is ALWAYS
>called, thus the form does not validate when submitting no file :
>
> require_once 'HTML/QuickForm.php';
> $form = & new HTML_QuickForm('builtin');
>
>
> $form->registerRule('webpic','rule','ImageWeb','ImageWeb.php');
> $form->addElement('file', 'picture', 'Picture:');
> $form->addRule('picture', 'Invalid Web picture', 'webpic');
>
> $form->addElement('submit');
> $form->validate();
> $form->display();
>
> (see attached code for the ImageWeb class)
>
>As it is the case with, for instance, an "email" rule, I would like my
>field to be validated only if a file has been uploaded.
>
>I didn't find any valuable informations on the web about usage of custom
>HTML_QuickForm_Rule classes. So I hope I didn't miss anything obvious,
>or is it just a bug/feature in HTML_QuickForm ?
I have checked and you are right. This is a bug not related to custom rules but
handling of empty file fields. Could you please file a bug for this, thanks
Bertrand Mansion
Mamasam