| john moylan 2005-10-22, 6:57 pm |
| 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] =3D 'Please Choose';
$main[1] =3D 'I like numbers';
$main[2] =3D 'I like letters';
$secondary[0][0] =3D "-----------------------";
$secondary[1][0] =3D 'Please Choose your fave number';
$secondary[1][1] =3D '88';
$secondary[1][2] =3D '99';
$secondary[1][3] =3D '7';
$secondary[1][4] =3D '42';
$secondary[1][5] =3D '55';
$secondary[2][0] =3D 'Please select your fave letter';
$secondary[2][1] =3D 'W';
$secondary[2][2] =3D 'F';
$secondary[2][3] =3D 'P';
$secondary[2][4] =3D 'S';
$secondary[2][5] =3D 'O';
$opts[] =3D $main;
$opts[] =3D $secondary;
$hs =3D& $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
|