/** * form definition */ public function definition() { $mform =& $this->_form; $mform->addElement('header', 'header', get_string('heading:info', 'block_coupon')); if (!($strinfo = get_config('block_coupon', 'info_coupon_course'))) { $strinfo = get_string('missing_config_info', 'block_coupon'); } $mform->addElement('static', 'info', '', $strinfo); $mform->addElement('header', 'header', get_string('heading:input_course', 'block_coupon')); // First we'll get some useful info. $courses = helper::get_visible_courses(); // And create data for multiselect. $arrcoursesselect = array(); foreach ($courses as $course) { $arrcoursesselect[$course->id] = $course->fullname; } $attributes = array('size' => min(20, count($arrcoursesselect))); // Course id. $selectcourse =& $mform->addElement('select', 'coupon_courses', get_string('label:coupon_courses', 'block_coupon'), $arrcoursesselect, $attributes); $selectcourse->setMultiple(true); $mform->addRule('coupon_courses', get_string('error:required', 'block_coupon'), 'required', null, 'client'); $mform->addHelpButton('coupon_courses', 'label:coupon_courses', 'block_coupon'); $this->add_action_buttons(true, get_string('button:next', 'block_coupon')); }