Here’s the formslib moodle doc:
$mform->addElement('editor', 'fieldname', get_string('labeltext', 'langfile'));
And this is supposed to be the 4th attribute parameter:
array(
'subdirs'=>0,
'maxbytes'=>0,
'maxfiles'=>0,
'changeformat'=>0,
'context'=>null,
'noclean'=>0,
'trusttext'=>0);
)
I tried:
$mform->addElement('editor', 'fieldname', get_string('labeltext', 'langfile'), array('context'=>'test"));
but doesn’t work. Any ideas?
I copied your example code into the forum module as a test (mod/forum/post_form.php) in Moodle 2.0 and managed to get an editor to display using the following:
It’s crucial to specify module context for form editor elements. Also, the fourth argument is reserved – you should use the fifth argument for setting context and other variables, although I believe both arguments actually work (!)
The form will now have <textarea id=”id_fieldname”> using the example code above.
If you want to specify a default value for the editor before the user has even input anything, you can use setValue() as a method call to the result of addElement():
I hope this answers your question – but please comment if there’s anything specific I can help with here.