2

I am upgrading one of my component to support Joomla 4 and I am getting this error in webpage

Call to undefined method Joomla\CMS\Editor\Editor::getContent

The code that throws this error is in views->tmpl->edit.php file:

var datdescription = <?php echo $this->editor->getContent( 'datdescription' ); ?>

When I checked Joomla Site for backward compatibility I could not find any solution. But when I checked this link https://api.joomla.org/cms-3/deprecated.html and searched for getContent I found this:

\Joomla\CMS\Editor\Editor::getContent()

deprecated Use Joomla.editors API, see core.js

Does anyone know how to solve this?

2

As it is explained in core.js: instead of using getContent() method you should use:

  • To get the current editor value:
Joomla.editors.instances['jform_articletext'].getValue();

Where jform_articletext means the textarea id and you have to change that value if your textarea id is something else. So in your case it could be for example:

let datdescription = Joomla.editors.instances['datdescription'].getValue();

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.