joomla custom component - add rich text support

544 Views Asked by At

I am developing a cusom component and I would like it to support rich text fields. Possibly the same way it is done in com_content.

in the form definition I have the following field:

<field
        name="description"
        type="editor"
        label="COM_MYCOMPONENT_DESCRIPTION_LABEL"
        description="COM_MYCOMPONENT_DESCRIPTION_DESC"
        class="inputbox"
        filter="MyComponentHelper::filterText"
        buttons="true"
    />

So basically what happens is that the editor appears as it is supposed to but the text is saved without formatting. The MyComponentHelper::filterText method was added later after investigating com_content and copying the filterText method to my helper, but it did not work either with or without the line. I even tried to use ContentHelper::filterText but without success.

2

There are 2 best solutions below

0
On BEST ANSWER

OK, so this was my bad. As I have followed the tutorial MyComponenetHelper ended up as an abstract class. I made it a normal class and everything works fine.

1
On

In joomla 1.5, you had to do this in the model (in function that does the saving):

$data['description'] = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);

if (!$row->bind($data)) {
   ...

Don't know if it still exists in Joomla 1.6. Hope it helps.