how to display text got from HTML EDITOR

how to display text got from HTML EDITOR

by Ye Chen -
Number of replies: 1
I have a maybe stupid question. I use HTML EDITOR to get information from user's input. Once I get the data, how I display it in HTML format instead of plain text.
my code is something like that $data=$mform->get_data();
echo $data->text;

text is the element name in the form which uses HTML Editor. It gives me plain text (this is my text ) instead of styled HTML text like (this is my text).

I know there must be very simple way to do it like use one moodle library function. I just don't know what it is. Is there anyone can help?

Thanks
Ye
Average of ratings: -
In reply to Ye Chen

Re: how to display text got from HTML EDITOR

by Paul Holden -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Ye,

Try try something like the following:

$fobj = new Object;
$fobj->para = false;
echo(format_text($data->text, FORMAT_MOODLE, $fobj));