NYCPHP Meetup

NYPHP.org

[nycphp-talk] Problem with Quickform and email rules

Steve Manes smanes at magpie.com
Thu Feb 17 12:09:45 EST 2005


I've got an application that's got an email element I want to validate. 
  This is being done through the Array/Smarty interface, if this matters.

The element is created:

$form->addElement('text', 'email', 'Email',
   array('size' => 30, 'maxlength' => 100));

Then I registered and added a rule:

$form->registerRule('emailcheck', 'function', 'emailCheck');
$form->addRule('email', 'Enter a valid email address',
   'emailcheck', 'function');

emailCheck() is a custom function in the same file.

Problem is, this rule never gets called.  I even dumped a phpinfo() in 
the function so I wouldn't miss its invocation.


So I tried using QuickForm's built-in email rule:

$form->addRule('email', 'Enter a valid email address',
    'email', null, 'server');

This too doesn't work no matter what garbage I put in the email field.


However, the 'required' rule works on it:

$form->addRule('email', 'Please enter an <b>Email</b> address.',
   'required');

If the email field is set, .errors get set with the error message.


What am I missing here??



More information about the talk mailing list