troubleshooting Question

Moodle Course custom field data not save

Avatar of Jibon Bikash Roy
Jibon Bikash Roy asked on
DatabasesPHP* Moodle
2 Comments1 Solution154 ViewsLast Modified:
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->setConstants('course_price', $course->course_price);


  $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?
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros