I am trying to move the selected items from one table to another and get this error:
A required parameter (id) was missing
$objs = array();
$objs[0] =& $mform->createElement('select', 'choosedepartments', get_string('Choose', 'dlist'), $table, $choices, 'size="25"');
$objs[0]->setMultiple(true);
$objs[1] =& $mform->createElement('select', "selecteddepartments", get_string('Select', 'dlist'), $schoices, 'size="15"');
$objs[1]->setMultiple(true);
$grp =& $mform->addElement('group', 'departmentgrp', get_string('Department list', 'dlist'), $objs, ' ', false);
//$objs[] =& $mform->addElement('submit', 'select', "Select");
$objs = array();
$objs[] =& $mform->createElement('submit', 'addsel', get_string('addsel', 'dlist'));
$objs[] =& $mform->createElement('submit', 'removesel', get_string('removesel', 'dlist'));
$objs[] =& $mform->createElement('submit', 'addall', get_string('addall', 'dlist'));
$objs[] =& $mform->createElement('submit', 'removeall', get_string('removeall', 'dlist'));
$grp =& $mform->addElement('group', 'buttonsgrp', get_string('selectedlist', 'dlist'), $objs, array(' ', '<br />'), false);
Why all the '=&' lines? Unless you're using PHP 4 (which isn't compatible with recent versions of Moodle), all objects are passed by reference without it.
It's not entirely clear what code is calling this form, but I assume that the page displaying the form has a line 'required_param('id', PARAM_INT);' somewhere in it. To fix this, you need to add an element in your form called 'id':
Whatever code is initialising the form, will also need to use 'setData' to pass in the correct value for 'id'.
e.g.
After that, should go the usual 'if ($form->isCancelled())', 'if ($data = $form->getData())' and '$form->display()' code.