function definition_after_data() { global $DB, $CFG, $USER; $request = new requests(); $mform = $this->_form; $program = $request->student_enrolled_program($USER->id); if (count($program) > 2) { $pid = $mform->getElementValue('programid'); if (isset($pid) && !empty($pid) && $pid[0] > 0) { $sem = $request->student_enrolled_sem($pid[0]); $one = $mform->createElement('select', 'semesterid', get_string('semester', 'local_request'), $sem); $mform->insertElementBefore($one, 'beforesem'); $mform->addRule('semesterid', get_string('required'), 'required', null, 'client'); } } }