Re: QuickForms AddGroupRule

From: Date: Thu, 01 Apr 2004 13:02:52 +0000
Subject: Re: QuickForms AddGroupRule
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11569@lists.php.net to get a copy of this message
<master1@megawap.ru> wrote : > 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(); Hi, Give a name to your group for example 'TimeEx' instead of null. Then use addGroupRule('TimeEx', 'Enter times!', 'noteq'); Not tested but that's the way to go. Bertrand Mansion Mamasam

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