Quickform CustomRules for hierselect

From: Date: Sat, 22 Oct 2005 18:08:08 +0000
Subject: Quickform CustomRules for hierselect
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21597@lists.php.net to get a copy of this message
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 ? thanks john

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