Hi,
Might be a late reply, but if you're trying to use this inside a regular moodleform instance somewhere, it won't work because of a bug in Moodle - https://tracker.moodle.org/projects/MDL/issues/MDL-59904
As I said in the ticket, I created a new class in my plugin called MoodleQuickForm_simpleeditor, saved as mod/myplugin/simpleeditor.php (not the real path, but one for example uses):
class MoodleQuickForm_simpleeditor extends MoodleQuickForm_editor {
public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
$this->_options['atto:toolbar'] = '';
parent::__construct($elementName, $elementLabel, $attributes, $options);
}
}
Then in my form definition I have:
public function definition() {
global $CFG;
// Load the files we're going to need.
require_once("$CFG->libdir/form/editor.php");
require_once("$CFG->dirroot/mod/myplugin/simpleeditor.php");
$mform = $this->_form;
require_once("$CFG->libdir/form/editor.php");
\MoodleQuickForm::registerElementType('simpleeditor', "$CFG->libdir/form/editor.php", 'MoodleQuickForm_simpleeditor');
$editoroptions = array(
'subdirs' => 0,
'maxbytes' => 0,
'maxfiles' => 0,
'changeformat' => 0,
'context' => null,
'noclean' => 0,
'trusttext' => 0,
'enable_filemanagement' => false,
'atto:toolbar' => 'style1 = bold, italic',
);
$mform->addElement('simpleeditor', 'mytextfield', null, null, $editoroptions);
$mform->setType('mytextfield', PARAM_RAW);
}
(My editor doesn't have a text label on it, but that's because I wanted it to be that way. You'd put the text label in place of the first null there.)
Hope this helps,
Peter