RE: [PEAR] QuickForms AddGroupRule

From: Date: Thu, 01 Apr 2004 12:55:43 +0000
Subject: RE: [PEAR] QuickForms AddGroupRule
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11568@lists.php.net to get a copy of this message
Hi, Should this line not have the right function name in it? $form->addGroupRule('TimeEx','Enter times!', 'notequal'); Ie. 'noteq' -> 'notequal' Maybe a small oversight ;-) Also, my solution was to just use the addFormRule() method and pass it a function name which can accept an array of all the forms fields. You can do what you want in there for validation. Regards, - Mike. > -----Original Message----- > From: Alexey Mirkulove [mailto:master1@megawap.ru] > Sent: 01 April 2004 12:47 > To: pear-general@lists.php.net > Subject: [PEAR] QuickForms AddGroupRule > > > Greetings! > Have a quetion about QuickForms -> > I want to check if two values in one group are not the same, > i understand > that i have to write my own function for this. > How values to a function transforms? And how i can check that > function is > registered? > > $form = new HTML_QuickForm('Master times'); > > $y=5; > $x="00"; > while ($y<22){ > $timex[$z]=$y . ":" . $x; > if ($x=="30"){$y=$y+1;$x="00";} else {$x="30";} > $z++; > } > > function notequal($fields, $values) > { > > if ($fields['stime'] == $fields['etime']) { > return false; > } else { > return true;} > } > > $form->registerRule ('noteq', 'function', 'notequal'); > $TimeEx['stime'] = > &HTML_QuickForm::createElement('select', 'stime' , > '', $timex); > $TimeEx['etime'] = > &HTML_QuickForm::createElement('select', 'etime' , > '', $timex); > $Butt[] = &HTML_QuickForm::createElement('submit','null', > 'Enter'); > $Butt[] = &HTML_QuickForm::createElement('reset','null', > 'Reset'); > > $form->addElement('header', null, 'Time table'); > $form->addElement('static', 'logname', "Greetings", $row[0]); > $form->addGroup($TimeEx, null , "from" ," to " ); > $form->addGroup($Butt, null, null, '&nbsp;'); > > $form->applyFilter('__ALL__', 'trim'); > $form->addGroupRule('TimeEx','Enter times!', 'noteq'); > > if ($form->validate()) { > echo '<h1>Thanks, ' . $row[0] . '!</h1>Times was inserted in > to DB<br>'; > } > > // Output the form > $form->display(); > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________

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