Re: Quickform CustomRules for hierselect

From: Date: Sat, 22 Oct 2005 20:08:21 +0000
Subject: Re: Quickform CustomRules for hierselect
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21605@lists.php.net to get a copy of this message
thanks for the tip, I'll have a look. On 10/22/05, Justin Patrin <papercrane@gmail.com> wrote: > On 10/22/05, john moylan <johnmoylan@gmail.com> wrote: > > Hello. > > > > Has anyone successfully created a custom ruleset for a hierselect? any > > tips on how to create them? > > > > Here's some dumy code, I don't seem to be able to validate the second > > hierselect select menu. > > > > # starts > > // Starts - Make a hierselect menu > > $main[0] = 'Please Choose'; > > $main[1] = 'I like numbers'; > > $main[2] = 'I like letters'; > > > > $secondary[0][0] = "-----------------------"; > > > > $secondary[1][0] = 'Please Choose your fave number'; > > $secondary[1][1] = '88'; > > $secondary[1][2] = '99'; > > $secondary[1][3] = '7'; > > $secondary[1][4] = '42'; > > $secondary[1][5] = '55'; > > > > $secondary[2][0] = 'Please select your fave letter'; > > $secondary[2][1] = 'W'; > > $secondary[2][2] = 'F'; > > $secondary[2][3] = 'P'; > > $secondary[2][4] = 'S'; > > $secondary[2][5] = 'O'; > > > > $opts[] = $main; > > $opts[] = $secondary; > > > > $hs =& $form->addElement('hierselect', 'multitest', 'Do > > you like > > numbers or letters', '', '<br />'); > > $hs->setOptions($opts); > > // Ends - Make a hierselect menu > > > > // Custom rule for hierselect > > function validate_hierselect($element_name, $element_value) { > > > > if(is_numeric($element_value)) { > > > > return true; > > } > > > > return false; > > } > > $form->registerRule('doValidation', 'function', > > validate_hierselect); > > $form->addRule('multitest', 'I called function > > validate_hierselect', > > 'doValidation'); > > # ends > > > > thinks: could this use a groupRule ? > > > > Sorry, didn't look in detail at your problem, but you can always use a formRule. > > -- > Justin Patrin >

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