Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.9.5
-
Fix Version/s: None
-
Component/s: Forms Library
-
Labels:None
-
Affected Branches:MOODLE_19_STABLE
Description
Hierselect is a class to dynamically create two or more HTML Select elements. The first select changes the content of the second select and so on. Hierselect is not defined in lib/formslib.php and in lib/form directory. This class is important to get data from users in signup.
Attached is a patch that implements the hierselect form element in moodle. It is built against Moodle 2.0 dev (Build: 20091231)
Usage is as follows:
// level 0 array
$letters = array();
$letters[0] = 'A';
$letters[1] = 'B';
$letters[2] = 'C';
// level 1 array
$words = array();
$words[0][0] = 'Aardvark';
$words[0][1] = 'Apple';
$words[0][2] = 'Armadillo';
$words[1][0] = 'Ball';
$words[1][1] = 'Banana';
$words[2][0] = 'Cat';
$words[2][1] = 'Chicken';
$words[2][2] = 'Can';
$words[2][3] = 'Cow';
// add hierselect element
$attribs = array('size' => '4');
$hier = &$mform->addElement('hierselect', 'list', get_string('categories', 'modulename'), $attribs);
$hier->setOptions(array($letters, $words));