1

I have a editor field which I would like to populate with HTML content:

<fieldset name="basic">
    <field name="Code" type="editor" label="Code" description="" width="300" filter="safehtml" default="" />
</fieldset>

Can this be achieved?

Thank you.

  • were you able to achieve what you seek. – Pratyush Aug 22 '18 at 8:27
1

You can create the editor dynamically in the getInput() as

protected function getInput() {
    $editor = JFactory::getEditor();
    return $editor->display($this->name, $this->value, '550', '400', '60', '20', false); }

If this doesn't help you can create it using the JHtml class

Hope this helps.

1

Assuming you mean the default value, add default element within the field and include the content wrapped with CDATA:

<fieldset name="basic">
    <field name="Code" type="editor" label="Code" description="" width="300" filter="safehtml">
        <default><![CDATA[<h1>Sample Text</h1>]]></default>
    </field>
</fieldset>
  • Hi Sharky, Thanks for this. Is it possible to add an editor field through a custom field type as I will be adding the data dynamically? Thanks. – Sergiu Tripon Aug 20 '18 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.