I have created a generic form that uses a editor in the form. I am able to save to the database but when I when try edit the record in the form the editor element only displays the default and not the record from the database.
I have the following editor element:
$mform->addElement('editor', 'forum_body', 'Forum Body');
$mform->setType('forum_body', PARAM_RAW);
$mform->setDefault('forum_body', array('text' => get_config('local_forum_events', 'defaultproperties_body'),'format' => FORMAT_HTML));
When the page loads I set the following data:
if($id) {
$dataforform = $DB->get_record('local_forum_events', array('id' => $id));
if($dataforform) {
$mform->set_data($dataforform);
} else {
throw new dml_exception("A record with id $id does not exist.");
}
}
I have done a var_dump on the $mform and i can see my data in the _defaults of the mform array but i am not sure why it doesnt get set.