We help IT Professionals succeed at work.

Moodle Course custom field data not save

Jibon Bikash Roy
on
145 Views
Last Modified: 2017-04-24
I have added a custom field in course page.

my form input code is in /course/edit_form.php

        $mform->addElement('text','course_price', get_string('course_price'),'maxlength="100"  size="10"');
        $mform->addHelpButton('course_price', 'course_price');
        $mform->setType('course_price', PARAM_RAW);
        if (!empty($course->id)) {
            $mform->hardFreeze('course_price');
            $mform->setConstants('course_price', $course->course_price);
        }

/course/lib.php

  $data->course_price  = !empty($data->course_price) ? $data->course_price :0;

// save data
$newcourseid = $DB->insert_record('course', $data);



but data not save in DB course table, give the error Error writing to database. Can anybody help me?
Comment
Watch Question

Most Valuable Expert 2011
Author of the Year 2014
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Most Valuable Expert 2011
Author of the Year 2014

Commented:
stale question