{"id":366,"date":"2016-02-20T12:22:42","date_gmt":"2016-02-20T06:52:42","guid":{"rendered":"http:\/\/www.magewallet.com\/?p=366"},"modified":"2020-03-13T16:09:35","modified_gmt":"2020-03-13T10:39:35","slug":"magento-2-how-to-display-wysiwyg-editor-in-admin-configuration-options","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/magento-2\/magento-2-how-to-display-wysiwyg-editor-in-admin-configuration-options\/","title":{"rendered":"Magento 2 &#8211; How to add WYSIWYG editor in admin configuration options?"},"content":{"rendered":"<p>In this blog post, we learn how to add WYSIWYG editor with textarea in admin system configuration options.<\/p>\n<p>First we will add one system config field in system.xml file. Use below code to add new field with the type Editor.<\/p>\n<pre class=\"lang:default decode:true \">&lt;field id=\"editortextarea\" translate=\"label\" type=\"editor\" sortOrder=\"10\" showInDefault=\"1\" showInWebsite=\"1\" showInStore=\"1\"&gt;\r\n\t&lt;label&gt;Textare with WYSIWYG&lt;\/label&gt;\r\n\t&lt;frontend_model&gt;Hiddentechies\\ConfigEditor\\Block\\Adminhtml\\System\\Config\\Editor&lt;\/frontend_model&gt;\r\n&lt;\/field&gt;<\/pre>\n<p>In order display WYSIWYG editor with this textarea we need one frontend block. so you can create editor.php file at below location.<\/p>\n<pre class=\"lang:default decode:true \">Hiddentechies\\ConfigEditor\\Block\\Adminhtml\\System\\Config<\/pre>\n<p>In this block you can write below code snippet.<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\nnamespace Hiddentechies\\ConfigEditor\\Block\\Adminhtml\\System\\Config;\r\n\r\nclass Editor extends \\Magento\\Config\\Block\\System\\Config\\Form\\Field {\r\n\r\n    protected $_wysiwygConfig;\r\n\r\n    public function __construct(\r\n    \\Magento\\Backend\\Block\\Template\\Context $context, \\Magento\\Cms\\Model\\Wysiwyg\\Config $wysiwygConfig, array $data = []\r\n    ) {\r\n        $this-&gt;_wysiwygConfig = $wysiwygConfig;\r\n        parent::__construct($context, $data);\r\n    }\r\n\r\n    protected function _getElementHtml(\\Magento\\Framework\\Data\\Form\\Element\\AbstractElement $element) {\r\n        $element-&gt;setWysiwyg(true);\r\n        $element-&gt;setConfig($this-&gt;_wysiwygConfig-&gt;getConfig($element));\r\n        return parent::_getElementHtml($element);\r\n    }\r\n\r\n}<\/pre>\n<p>Now please clear cache file and then go to module system configuration, you will get textarea with WYSIWYG option.<\/p>\n<p>That&#8217;s it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, we learn how to add WYSIWYG editor with textarea in admin system configuration options. First we will add one system config field in system.xml file. Use below code to add new field with the type Editor. &lt;field id=&#8221;editortextarea&#8221; translate=&#8221;label&#8221; type=&#8221;editor&#8221; sortOrder=&#8221;10&#8243; showInDefault=&#8221;1&#8243; showInWebsite=&#8221;1&#8243; showInStore=&#8221;1&#8243;&gt; &lt;label&gt;Textare with WYSIWYG&lt;\/label&gt; &lt;frontend_model&gt;Hiddentechies\\ConfigEditor\\Block\\Adminhtml\\System\\Config\\Editor&lt;\/frontend_model&gt; &lt;\/field&gt; In order&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/magento-2\/magento-2-how-to-display-wysiwyg-editor-in-admin-configuration-options\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":4890,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[81,10],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/366"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=366"}],"version-history":[{"count":3,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/366\/revisions"}],"predecessor-version":[{"id":10932,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/366\/revisions\/10932"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/4890"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}