All pastes #91300 Raw Edit

pilpi

public php v1 · immutable
#91300 ·published 2006-07-18 13:44 UTC
rendered paste body
<?php/* *  * Test file for QuickForm bug(?). * For grouped elements, the values for  * which are tested with a custom function, * the rule never prints out the error message * ("fields don't match rule"), although the * test is performed and quickform correctly * acts according to the boolean result the  * function gives. The same problem applies * to quickform's built-in compare.  *  * Also, I found it strange that the array given  * to the testing function  *  * Array ( [0] => a [1] => a )  *  * is quite different from the array given to the success function *  * Array ( [arrname] => Array ( [time] => a [room] => a ) [save] => submit ) *  */function tester($form_data_array){	echo "tester:<br />";	print_r($form_data_array);	echo "<br />";	return false;	//return true;}require 'HTML/QuickForm.php';$form = new HTML_QuickForm('test');$arr=array();$arr['a'] =& HTML_QuickForm::createElement('text','time',"time_");$arr['b'] =& HTML_QuickForm::createElement('text','room',"room_");$ret=$form->addGroup(&$arr, 'arrname','fields:', ',&nbsp'); //, NULL,NULL,FALSE$form->addGroupRule('arrname',"all fields are required",'required');$ret2= $form->addRule(array('arrname[time]','arrname[room]'),               "fields don't match rule",'callback',"tester", NULL, NULL, TRUE);// uncomment this and the above comment (//, NULL,NULL,FALSE): still doesn't work// $form->addRule(array('prereserve_time]','prereserve_room]'),//               "fields don't match rule",'callback',"make_prereservation", NULL, NULL, TRUE);// or uncomment this: doesn't work with compare, either//$form->addRule(array('arrname[time]','arrname[room]'),//               "fields don't match each other",'compare',NULL, NULL, NULL, TRUE);echo "<pre>";//print_r ($ret->getElements()); // contains the elementsecho "</pre>";//echo "..".($form->elementExists('arrname[time]'))."..<br />"; // echoes "...."$form->addElement('submit','save','submit');/*if (PEAR::isError($ret)) {     echo $ret->getMessage();    echo $ret->getUserInfo();    var_dump($ret);}if (PEAR::isError($ret2)) {     echo $ret->getMessage();    echo $ret->getUserInfo();    var_dump($ret);}*/if ($form->validate()) {	$form->process('success');	} else {	$form->display();}// Define a function to process the form datafunction success($v) {	global $subjects;	echo "success! results: <br /> ";	print_r ($v);}?>