0

Today I'm using the textarea to fields in my custom module, but I want to improve with the WYSIWYG.

How could I use WYSIWYG in a custom field in the admin configuration panel that my module creates?

Thanks

5

Add following code in your file.

app/code/Namespace/Modulename/Block/Adminhtml/ModuleFolder/Edit/Tab/Main.php

protected $wysiwyg;

public function __construct(
    \Magento\Cms\Model\Wysiwyg\Config $wysiwyg
    ){
       $this->wysiwyg = $wysiwyg;
     }

$fieldset->addField(
            'fieldname',
            'editor',
            [
                'name' => 'fieldname',
                'label' => __('Fieldname'),
                'title' => __('Fieldname'),
                 'config'    => $this->wysiwyg->getConfig(),
                'wysiwyg'   => true
            ]
        );

Done. You can see WYSIWYG in your Admin form of your Custom Module.

0

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.