Re: PEAR QuickForm Problems Verifying date.

From: Date: Wed, 02 Jul 2003 14:40:36 +0000
Subject: Re: PEAR QuickForm Problems Verifying date.
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-6389@lists.php.net to get a copy of this message
Thank you very much, that did work! function checkData($elementName, $data) { return checkdate ($data['m'],$data['d'],$data['Y']); } $form->registerRule('checkdata', 'function', 'checkData'); $form->addRule('DataReportMin', 'Data incorrecte', 'checkdata', true); Ben "Bertrand Mansion" <bmansion@mamasam.com> escribió en el mensaje news:BB28A13D.9DC7%bmansion@mamasam.com... <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

« previous php.pear.general (#6389) next »