QuickForm : problem with a custom rule

From: Date: Wed, 16 Feb 2005 19:37:07 +0000
Subject: QuickForm : problem with a custom rule
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-36229@lists.php.net to get a copy of this message
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 ? Regards, Frederic Poeydomenge.

Attachment: [application/x-httpd-php] ImageWeb.php
« previous php.pear.dev (#36229) next »