Skip to content

How to enable wysiwyg editor for custom attribute in admin category page?

I have created a custom category attribute using below code.

AyakilCustomCategoryAttributeSetupPatchDataAddMyDescriptionCategoryAttribute.php

public function apply()
{
    $this->moduleDataSetup->getConnection()->startSetup();
    /** @var EavSetup $eavSetup */
    $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
    $eavSetup->addAttribute(
        MagentoCatalogModelCategory::ENTITY,
        'my_description',
        [
            'type' => 'text',
            'label' => 'my_description',
            'input' => 'textarea',
            'sort_order' => 444,
            'source' => '',
            'global' => ScopedAttributeInterface::SCOPE_WEBSITE,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'default' => null,
            'group' => 'General Information',
            'backend' => '',
            'wysiwyg_enabled' => true,
            'is_wysiwyg_enabled'  => true,
            'is_html_allowed_on_front' => true,
        ]
    );

    $this->moduleDataSetup->getConnection()->endSetup();
}

AyakilCustomCategoryAttributeviewadmin_htmlui_componentcategory_form.xml

<field name="my_description" template="ui/form/field" sortOrder="150" formElement="wysiwyg">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="wysiwygConfigData" xsi:type="array">
                    <item name="height" xsi:type="string">100px</item>
                    <item name="add_variables" xsi:type="boolean">false</item>
                    <item name="add_widgets" xsi:type="boolean">false</item>
                    <item name="add_images" xsi:type="boolean">true</item>
                    <item name="add_directives" xsi:type="boolean">true</item>
                </item>
                <item name="source" xsi:type="string">category</item>
            </item>
        </argument>
        <settings>
            <label translate="true">My Description</label>
            <notice translate="true">Note: Keyboard shortcut to activate editor help : Alt + 0 (Windows) or &#x2325;0 (MacOS)</notice>
            <dataScope>my_description</dataScope>
        </settings>
        <formElements>
            <wysiwyg class="MagentoCatalogUiComponentCategoryFormElementWysiwyg">
                <settings>
                    <rows>8</rows>
                    <wysiwyg>true</wysiwyg>
                </settings>
            </wysiwyg>
        </formElements>
    </field>

This will add the My description field in category as below
enter image description here

But when i go to the Schedule Changes and clic Schedule New Update Button i’m not getting the wysiwyg editor there.
enter image description here

Can anyone please tell me what i am missing here.