selecting multiple values from db

selecting multiple values from db

by eran nokrean -
Number of replies: 0

Hi,


I'm creating a new form in my admin panel, which has a multiple selection window.

The function itself works fine, but I can't make the form load the current selection when re-entering.

Here is the relevant part:

$courses=$DB->get_records('course');

$options=array();

foreach($courses as $course){

$options[$course->id] = $course->fullname;

}

$select = $mform->addElement('select', 'courses', 'Select Courses', $options,'size="10"');

$select->setMultiple(true);

$select->setSelected(json_decode($coupon->courses)); // fix


Problem is - the setSelected line is just not working.


Appreciate your help

Average of ratings: -