Re: PEAR QuickForm Problems Verifying date.
| From: | Bertrand Mansion | Date: | Wed, 02 Jul 2003 12:48:29 +0000 |
| Subject: | Re: PEAR QuickForm Problems Verifying date. | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-6383@lists.php.net to get a copy of this message | ||
<benji@autec.es> wrote :
> I want to validate a date pear field with checkdate function from php to
> validate if its valid gregorian date, what is my error?, if I pfrint the
> value for $data inside checkData function I obtain a string:"DataReportMin",
> when what I would expect is an array containing [d]-> [m]-> [Y]-> so I
> could verify it.
> Is this a bug? or a should do? Or Am I mistaking anything...
>
> Code:
>
> $form->addElement('date', 'DataReportMin', 'Data Report
> Minima:',
> array('format'=>'dmY', 'minYear'=>1999,
> 'maxYear'=>$year));
>
> function checkData($data, $domainCheck = false)
> {
> return checkdate ($data['m'],$data['d'],$data['Y']);
> }
>
> $form->registerRule('checkdata', 'function', 'checkData');
> $form->addRule('DataReportMin', 'Data incorrecta',
> 'checkdata', true);
>
>
>
Your validation function should be:
function checkData($elementName, $data, $options)
You can safely get rid of the $options if you don't need any option in your
addRule.
Bertrand Mansion
Mamasam