I want to add WYSIWYG enabled textareas as custom fields for categories. I have read all related topics on this site for this issue, but none of the mentioned answers seem to do the trick. Can somebody see what I'm doing wrong?
Note: This is Magento 2.3 - The module works, the attributes are created properly, data is saved correctly, but the WYSIWYG won't show. The configuration setting for WYSIWYG fields is correct too.
/app/code/MyCompant/CategoryFields/Setup/InstallData.php
class InstallData implements InstallDataInterface
{
private $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(
Category::ENTITY,
'sm_category_faq1_content',
[
'type' => 'varchar',
'label' => 'FAQ1 Content',
'input' => 'textarea',
'required' => false,
'sort_order' => 102,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'is_wysiwyg_enabled' => true,
'is_html_allowed_on_front' => true,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]
);
}
}
/app/code/MyCompany/CategoryFields/view/adminhtml/ui_component/category_form.xml
<fieldset name="custom_content">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Custom Content</item>
<item name="collapsible" xsi:type="boolean">true</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
<field name="sm_category_faq1_content">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="class" xsi:type="string">Magento\Catalog\Ui\Component\Category\Form\Element\Wysiwyg</item>
<item name="formElement" xsi:type="string">wysiwyg</item>
<item name="label" xsi:type="string" translate="true">FAQ1 Content</item>
<item name="wysiwygConfigData" xsi:type="array">
<item name="settings" xsi:type="array">
<item name="theme_advanced_buttons1" xsi:type="string">bold,italic,|,justifyleft,justifycenter,justifyright,|,fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,|,code</item>
<item name="theme_advanced_buttons2" xsi:type="boolean">false</item>
<item name="theme_advanced_buttons3" xsi:type="boolean">false</item>
<item name="theme_advanced_buttons4" xsi:type="boolean">false</item>
<item name="theme_advanced_statusbar_location" xsi:type="boolean">false</item>
</item>
<item name="files_browser_window_url" xsi:type="boolean">false</item>
<item name="height" xsi:type="string">250px</item>
<item name="toggle_button" xsi:type="boolean">false</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">false</item>
</item>
<item name="template" xsi:type="string">ui/form/field</item>
<item name="source" xsi:type="string">category</item>
<item name="wysiwyg" xsi:type="boolean">true</item>
<item name="dataScope" xsi:type="string">sm_category_faq1_content</item>
<item name="sortOrder" xsi:type="number">12</item>
<item name="rows" xsi:type="number">8</item>
</item>
</argument>
</field>
</fieldset>
</form>
-
Please check your admin configuration Stores->Configuration->General->Content Management->WYSIWYG Options->Enable WYSIWYG Editor Set to "Disabled By Default" or "Enabled By Default". If it is set to "Disabled Completely" you will get only TextareaRonak Rathod– Ronak Rathod2019年09月10日 14:24:43 +00:00Commented Sep 10, 2019 at 14:24
-
I also checked that already, that's not the issue.Asitis– Asitis2019年09月10日 14:26:30 +00:00Commented Sep 10, 2019 at 14:26
1 Answer 1
'is_wysiwyg_enabled' => true, should be 'wysiwyg_enabled' => true
-
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From ReviewJarnail S– Jarnail S2020年01月15日 12:51:11 +00:00Commented Jan 15, 2020 at 12:51
-
1How does it not provide an answer? He has code in which I see the issue. And the issue is that he uses is_wysiwyg_enabled instead of wysiwyg_enabled. There is not much explanation to give. That's just how it isKevinvhengst– Kevinvhengst2020年01月15日 13:37:46 +00:00Commented Jan 15, 2020 at 13:37
-
I agree! My question was "what am I doing wrong" and this answers it just fine. However, I changed this and reinstalled without any change..Asitis– Asitis2020年01月15日 14:04:55 +00:00Commented Jan 15, 2020 at 14:04
-
Did you also make sure the field was removed from the database? Just reinstalling the module is not sufficient if the field was still in the database. You should remove the module form the
setup_modulestable to be sure thesetupscript runs again, and the fields should be remove fromeav_attributetable. Using a back-up of the database is often more quick. Also, you could usemagerun2, a tool build aroundbin/magentowhich has a command line command to remove EAV fields from your database through the CLI.Kevinvhengst– Kevinvhengst2020年01月15日 14:11:12 +00:00Commented Jan 15, 2020 at 14:11 -
1I added some more info to my previous comment :-)Kevinvhengst– Kevinvhengst2020年01月15日 14:15:52 +00:00Commented Jan 15, 2020 at 14:15
Explore related questions
See similar questions with these tags.