How to insert/update dropdwon value in moodle database in course form?

How to insert/update dropdwon value in moodle database in course form?

by Usman Jamil -
Number of replies: 0

I am trying to add a new dropdown menu on the course form where we can create a new course. This drop down menu have the values 'Full Day', 'Half Day' as course type. Created a column in mdl_course table named as course_type of type VARCHAR. Can't manage to modify the form.

i have created an array of choices, following is the code:

$choices = array();

$choices['0'] = 'Full Day';

 $choices['1'] = 'Half Day';

 $mform->addElement('select','course_type', 'Course Type', $choices);

 $mform->addRule('course_type', null, 'client'); $mform->setType('course_type', PARAM_RAW);


I put my code in edit_form.php file. I have also add a text input and store it in moodle database, it works fine but when I create dropdown list its not working. Following is the code for text input that works fine:

$mform->addElement('text','location', 'Location','maxlength="100" size="20"');

$mform->addRule('location', 'Misssing Location', null, 'client');

$mform->setType('location', PARAM_RAW);


Have any one tried this type of customization. Please help on this.

Thanks in advance.

Regards,

Usman

Attachment Course Type.PNG
Average of ratings: -