quickform addGroupRule question

From: Date: Sun, 26 Jan 2003 16:20:03 +0000
Subject: quickform addGroupRule question
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3471@lists.php.net to get a copy of this message
I would like to use quickform and date/calc.php to do som basic date verification. The following code doesn't work. Is there another way to get this to work? ====================================== <?php require_once ("HTML/QuickForm.php"); require_once("Date/Calc.php"); $form =& new HTML_QuickForm(); $test_date['month'] = &HTML_QuickForm::createElement('select', 'month', '', array('0' => '-month-', '1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10' => 'October', '11' => 'November', '12' => 'December')); $test_date['day'] = &HTML_QuickForm::createElement('text', 'day', '', 'size=2 maxlength=2'); $test_date['year'] = &HTML_QuickForm::createElement('text', 'year', '', 'size=4 maxlength=4'); $form->addElementGroup($test_date, 'Next Session (month, day, year):', 'test_date'); $form->addElement('submit', 'save_button', 'Save'); $form->applyFilter('__ALL__', 'trim'); $form->registerRule("validDateFormat", "function", "validDateFormat"); $form->addGroupRule('test_date', 'Values must be numeric', 'numeric'); $form->addGroupRule('test_date', 'Invalid date', 'validDateFormat'); if ($form->validate()) { echo "done"; exit; } function validDateFormat($element, $value, $defaultValue) { extract($_POST["test_date"], EXTR_OVERWRITE); return Date_Calc::isValidDate($day, $month, $year); } $form->display(); ?>

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