1

I want to add wysiwyg editor in store configuration. I added also. But, when I click on "Insert Variable" it's return error :

Uncaught ReferenceError: MagentovariablePlugin is not defined

How to solve this error?

Any help would be appreciated !!

Thanks!!

1

I found answer for that. Follow this below steps to solve this issue :

Add Field in system.xml file :

<field id="wysiwyg_editor" translate="wysiwyg" sortOrder="4" type="editor" showInStore="1" showInDefault="1" >
    <label>wysiwyg editor</label>
    <frontend_model>Vendor\Module\Block\Adminhtml\System\Config\Editor</frontend_model>
</field>

Now, create file for add wysiwyg editor in element :

app\code\Vendor\Module\Block\Adminhtml\System\Config\Editor.php

<?php

namespace Vendor\Module\Block\Adminhtml\System\Config;

use Magento\Framework\Registry;
use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;
use Magento\Framework\Data\Form\Element\AbstractElement;

class Editor extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @var  Registry
*/
protected $_coreRegistry;
/**
* @param Context    $context
* @param WysiwygConfig $wysiwygConfig
* @param array      $data
*/


public function __construct(
     Context $context,
     WysiwygConfig $wysiwygConfig,
     array $data = []
) {
     $this->_wysiwygConfig = $wysiwygConfig;
     parent::__construct($context, $data);
}
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
     // set wysiwyg for element
     $element->setWysiwyg(true);

     // set configuration values
     $element->setConfig($this->_wysiwygConfig->getConfig($element));

     return parent::_getElementHtml($element);
}
}

Now, create adminhtml_system_config_edit.xml for update editor handle :

app\code\Vendor\Module\view\adminhtml\layout\adminhtml_system_config_edit.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="editor"/>
</page>

Clean cache and it's working.

| improve this answer | |
  • 1+...Thnk You.. – Rk Rathod Dec 13 '19 at 9:24

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.