General developer forum

Prepopulate a moodle form editor with content

 
Raymond
Prepopulate a moodle form editor with content
 

Hello.

I need help with figuring out how I can prepopulate a moodle form with data from my database. I have an edit_feedback.php page which allows some of our teachers to edit whatever they have posted previously (grammatical errors, uploading a few extra files, etc)

I don't know how I can do this. I need to fetch the data from my database, and prepopulate the editor for the teacher to be able to edit.

Thank you.

 
Average of ratings: -
Picture of Neill Magill
Re: Prepopulate a moodle form editor with content
Core developersPlugin developers

Moodle forms have a set_data() method that allows you to populate the form.

You pass an array or object containing data you wish to populate your form with, the key/property names need to match the field names of the form.

 
Average of ratings: -