Custom Form with WYSIWYG Element: No content update and “Show / Hide Editor” Button does not workTarget element not found for content updateShow WYSIWYG button below custom category attributeHow to add WYSIWYG editor button in phtml formMagento Insert Image on WYSIWYG editor does not show imagesShow/Hide Editor Not RespondingHow to add WYSIWYG editor button editor in backend block formMagento 2 Add new field to Magento_User admin formForm is not displayed on panel admin Magento 2Magento 2 wysiwyg editor does not load folderShow/Hide Editor not working in magento 2.2.4

Where can I find a database of galactic spectra?

Inverse-quotes-quine

Apply brace expansion in "reverse order"

How do I turn off a repeating trade?

How do I set an alias to a terminal line?

What's currently blocking the construction of the wall between Mexico and the US?

What is the origin of Scooby-Doo's name?

When to make kiddush at a Seder with no wine?

Why is the voltage measurement of this circuit different when the switch is on?

Unusual mail headers, evidence of an attempted attack. Have I been pwned?

Find the C-factor of a vote

Can White Castle?

How convert text to hex value?

How does metta sutra develop loving kindness

Would it be a copyright violation if I made a character’s full name refer to a song?

Links to webpages in books

Hot coffee brewing solutions for deep woods camping

Is using weak login credentials always bad?

Can humans ever directly see a few photons at a time? Can a human see a single photon?

What was the Shuttle Carrier Aircraft escape tunnel?

Can Ogre clerics use Purify Food and Drink on humanoid characters?

What is the legal status of travelling with methadone in your carry-on?

Has there been any indication at all that further negotiation between the UK and EU is possible?

What is this tool/thing in an Aztec painting?



Custom Form with WYSIWYG Element: No content update and “Show / Hide Editor” Button does not work


Target element not found for content updateShow WYSIWYG button below custom category attributeHow to add WYSIWYG editor button in phtml formMagento Insert Image on WYSIWYG editor does not show imagesShow/Hide Editor Not RespondingHow to add WYSIWYG editor button editor in backend block formMagento 2 Add new field to Magento_User admin formForm is not displayed on panel admin Magento 2Magento 2 wysiwyg editor does not load folderShow/Hide Editor not working in magento 2.2.4






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a problem with enabling the WYSIWYG editor in a custom admin form. With a normal textarea, everything works:



 $fieldset->addField('slider_content', 'textarea', array(
'name' => 'content',
'label' => $helper->__('Content text'),
));


Now I change it to WYSIWYG:



 $fieldset->addField('slider_content', 'editor', array(
'name' => 'content',
'label' => $helper->__('Content text'),
'wysiwyg' => true,
'config' => Mage::getSingleton('cms/wysiwyg_config'),
));


And this is the layout update to include necessary JS:



 <reference name="head">
<action method="setCanLoadExtJs"><flag>1</flag></action>
<action method="setCanLoadTinyMce"><flag>1</flag></action>
<action method="addJs"><script>mage/adminhtml/variables.js</script></action>
<action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
<action method="addJs"><script>prototype/window.js</script></action>
<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
</reference>


Result:



Screenshot (Form)Screenshot (Firebug)



The button does not do anything visible. The hidden textarea exists and the highlighting in Firebug suggests that it is updated on click, but it stays hidden. Also it does not update its content when I make changes in the editor, so that when I save, nothing changes.



Any idea what the reason for this might be? There are no errors in the JavaScript console.










share|improve this question






















  • Try changing the config to Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/')),

    – Renon Stewart
    Nov 23 '15 at 17:42












  • @R.S It dit not make a difference. I found out that the problem is related to multiple tabs that all contained field with the same id

    – Fabian Schmengler
    Nov 24 '15 at 7:53

















0















I have a problem with enabling the WYSIWYG editor in a custom admin form. With a normal textarea, everything works:



 $fieldset->addField('slider_content', 'textarea', array(
'name' => 'content',
'label' => $helper->__('Content text'),
));


Now I change it to WYSIWYG:



 $fieldset->addField('slider_content', 'editor', array(
'name' => 'content',
'label' => $helper->__('Content text'),
'wysiwyg' => true,
'config' => Mage::getSingleton('cms/wysiwyg_config'),
));


And this is the layout update to include necessary JS:



 <reference name="head">
<action method="setCanLoadExtJs"><flag>1</flag></action>
<action method="setCanLoadTinyMce"><flag>1</flag></action>
<action method="addJs"><script>mage/adminhtml/variables.js</script></action>
<action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
<action method="addJs"><script>prototype/window.js</script></action>
<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
</reference>


Result:



Screenshot (Form)Screenshot (Firebug)



The button does not do anything visible. The hidden textarea exists and the highlighting in Firebug suggests that it is updated on click, but it stays hidden. Also it does not update its content when I make changes in the editor, so that when I save, nothing changes.



Any idea what the reason for this might be? There are no errors in the JavaScript console.










share|improve this question






















  • Try changing the config to Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/')),

    – Renon Stewart
    Nov 23 '15 at 17:42












  • @R.S It dit not make a difference. I found out that the problem is related to multiple tabs that all contained field with the same id

    – Fabian Schmengler
    Nov 24 '15 at 7:53













0












0








0








I have a problem with enabling the WYSIWYG editor in a custom admin form. With a normal textarea, everything works:



 $fieldset->addField('slider_content', 'textarea', array(
'name' => 'content',
'label' => $helper->__('Content text'),
));


Now I change it to WYSIWYG:



 $fieldset->addField('slider_content', 'editor', array(
'name' => 'content',
'label' => $helper->__('Content text'),
'wysiwyg' => true,
'config' => Mage::getSingleton('cms/wysiwyg_config'),
));


And this is the layout update to include necessary JS:



 <reference name="head">
<action method="setCanLoadExtJs"><flag>1</flag></action>
<action method="setCanLoadTinyMce"><flag>1</flag></action>
<action method="addJs"><script>mage/adminhtml/variables.js</script></action>
<action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
<action method="addJs"><script>prototype/window.js</script></action>
<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
</reference>


Result:



Screenshot (Form)Screenshot (Firebug)



The button does not do anything visible. The hidden textarea exists and the highlighting in Firebug suggests that it is updated on click, but it stays hidden. Also it does not update its content when I make changes in the editor, so that when I save, nothing changes.



Any idea what the reason for this might be? There are no errors in the JavaScript console.










share|improve this question














I have a problem with enabling the WYSIWYG editor in a custom admin form. With a normal textarea, everything works:



 $fieldset->addField('slider_content', 'textarea', array(
'name' => 'content',
'label' => $helper->__('Content text'),
));


Now I change it to WYSIWYG:



 $fieldset->addField('slider_content', 'editor', array(
'name' => 'content',
'label' => $helper->__('Content text'),
'wysiwyg' => true,
'config' => Mage::getSingleton('cms/wysiwyg_config'),
));


And this is the layout update to include necessary JS:



 <reference name="head">
<action method="setCanLoadExtJs"><flag>1</flag></action>
<action method="setCanLoadTinyMce"><flag>1</flag></action>
<action method="addJs"><script>mage/adminhtml/variables.js</script></action>
<action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>
<action method="addJs"><script>prototype/window.js</script></action>
<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
</reference>


Result:



Screenshot (Form)Screenshot (Firebug)



The button does not do anything visible. The hidden textarea exists and the highlighting in Firebug suggests that it is updated on click, but it stays hidden. Also it does not update its content when I make changes in the editor, so that when I save, nothing changes.



Any idea what the reason for this might be? There are no errors in the JavaScript console.







magento-1.9 adminhtml adminform wysiwyg enterprise-1.14






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '15 at 16:18









Fabian SchmenglerFabian Schmengler

55.4k21 gold badges145 silver badges359 bronze badges




55.4k21 gold badges145 silver badges359 bronze badges












  • Try changing the config to Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/')),

    – Renon Stewart
    Nov 23 '15 at 17:42












  • @R.S It dit not make a difference. I found out that the problem is related to multiple tabs that all contained field with the same id

    – Fabian Schmengler
    Nov 24 '15 at 7:53

















  • Try changing the config to Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/')),

    – Renon Stewart
    Nov 23 '15 at 17:42












  • @R.S It dit not make a difference. I found out that the problem is related to multiple tabs that all contained field with the same id

    – Fabian Schmengler
    Nov 24 '15 at 7:53
















Try changing the config to Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/')),

– Renon Stewart
Nov 23 '15 at 17:42






Try changing the config to Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/')),

– Renon Stewart
Nov 23 '15 at 17:42














@R.S It dit not make a difference. I found out that the problem is related to multiple tabs that all contained field with the same id

– Fabian Schmengler
Nov 24 '15 at 7:53





@R.S It dit not make a difference. I found out that the problem is related to multiple tabs that all contained field with the same id

– Fabian Schmengler
Nov 24 '15 at 7:53










2 Answers
2






active

oldest

votes


















2














This happens because you name your field content. Then the TinyMCE js looks for the element with id content to apply the editor. But there is already a content element on the page and it's a div.



Adding a prefix to the form elements solves this issue because the element does not have the id content anymore. It has something_content.

You can add this prefix with one line of code.



$form->setHtmlIdPrefix('something_');


Doing this, you don't need to alter the form data you pass to $form->addValues to add your prefix. It will all be done automatically.



The id prefix can be different for each tab if you have multiple tabs.






share|improve this answer

























  • Close. I already used "slider_content" as id because otherwise the whole "content" block turned into an editor :) The remaining "content" only determines the name, which is already modified by addFieldNameSuffix() to have a different name on each tab. setHtmlIdPrefix() sounds like a good idea, but all tabs are within one form. If you have a solution for using a different prefix in different fieldsets of the same form, I'll happily accept the answer.

    – Fabian Schmengler
    Nov 24 '15 at 8:49











  • @fschmengler. $form = new Varien_Data_Form(); in each tab. Then you will have different instances of Varien_Data_Form in each tab. This will work because the elements are moved via js in an other <form> anyway. The core does the same thing. Check this for example: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/… and this: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/…

    – Marius
    Nov 24 '15 at 9:02












  • Of course.. these are already separate Varien_Form instances. Thanks Marius, for the clean solution!

    – Fabian Schmengler
    Nov 24 '15 at 9:08


















1














The form was on a tab widget and as soon as there were multiple tabs, the elements had duplicate ids, this is what broke the editor. I added a unique prefix $elementIdPrefix for each tab, this solved the issue:



$fieldset->addField($elementIdPrefix . 'content', 'editor', array(
'name' => 'content',
'label' => $helper->__('Content text (top)'),
'wysiwyg' => true,
'config' => $wysiwygConfig,
));


To still be able to populate the form with data from a model, which is done based on the element id, I used the following code to add data:



$slideData = $this->_getCurrentSlide()->getData();
$formData = array();
foreach($slideData as $key => $value)
$formData[$elementIdPrefix . $key] = $value;

$form->addValues($formData);


$this->_getCurrentSlide() returns the model, previously the code was just:



$form->addValues($this->_getCurrentSlide());





share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f91264%2fcustom-form-with-wysiwyg-element-no-content-update-and-show-hide-editor-but%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    This happens because you name your field content. Then the TinyMCE js looks for the element with id content to apply the editor. But there is already a content element on the page and it's a div.



    Adding a prefix to the form elements solves this issue because the element does not have the id content anymore. It has something_content.

    You can add this prefix with one line of code.



    $form->setHtmlIdPrefix('something_');


    Doing this, you don't need to alter the form data you pass to $form->addValues to add your prefix. It will all be done automatically.



    The id prefix can be different for each tab if you have multiple tabs.






    share|improve this answer

























    • Close. I already used "slider_content" as id because otherwise the whole "content" block turned into an editor :) The remaining "content" only determines the name, which is already modified by addFieldNameSuffix() to have a different name on each tab. setHtmlIdPrefix() sounds like a good idea, but all tabs are within one form. If you have a solution for using a different prefix in different fieldsets of the same form, I'll happily accept the answer.

      – Fabian Schmengler
      Nov 24 '15 at 8:49











    • @fschmengler. $form = new Varien_Data_Form(); in each tab. Then you will have different instances of Varien_Data_Form in each tab. This will work because the elements are moved via js in an other <form> anyway. The core does the same thing. Check this for example: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/… and this: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/…

      – Marius
      Nov 24 '15 at 9:02












    • Of course.. these are already separate Varien_Form instances. Thanks Marius, for the clean solution!

      – Fabian Schmengler
      Nov 24 '15 at 9:08















    2














    This happens because you name your field content. Then the TinyMCE js looks for the element with id content to apply the editor. But there is already a content element on the page and it's a div.



    Adding a prefix to the form elements solves this issue because the element does not have the id content anymore. It has something_content.

    You can add this prefix with one line of code.



    $form->setHtmlIdPrefix('something_');


    Doing this, you don't need to alter the form data you pass to $form->addValues to add your prefix. It will all be done automatically.



    The id prefix can be different for each tab if you have multiple tabs.






    share|improve this answer

























    • Close. I already used "slider_content" as id because otherwise the whole "content" block turned into an editor :) The remaining "content" only determines the name, which is already modified by addFieldNameSuffix() to have a different name on each tab. setHtmlIdPrefix() sounds like a good idea, but all tabs are within one form. If you have a solution for using a different prefix in different fieldsets of the same form, I'll happily accept the answer.

      – Fabian Schmengler
      Nov 24 '15 at 8:49











    • @fschmengler. $form = new Varien_Data_Form(); in each tab. Then you will have different instances of Varien_Data_Form in each tab. This will work because the elements are moved via js in an other <form> anyway. The core does the same thing. Check this for example: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/… and this: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/…

      – Marius
      Nov 24 '15 at 9:02












    • Of course.. these are already separate Varien_Form instances. Thanks Marius, for the clean solution!

      – Fabian Schmengler
      Nov 24 '15 at 9:08













    2












    2








    2







    This happens because you name your field content. Then the TinyMCE js looks for the element with id content to apply the editor. But there is already a content element on the page and it's a div.



    Adding a prefix to the form elements solves this issue because the element does not have the id content anymore. It has something_content.

    You can add this prefix with one line of code.



    $form->setHtmlIdPrefix('something_');


    Doing this, you don't need to alter the form data you pass to $form->addValues to add your prefix. It will all be done automatically.



    The id prefix can be different for each tab if you have multiple tabs.






    share|improve this answer















    This happens because you name your field content. Then the TinyMCE js looks for the element with id content to apply the editor. But there is already a content element on the page and it's a div.



    Adding a prefix to the form elements solves this issue because the element does not have the id content anymore. It has something_content.

    You can add this prefix with one line of code.



    $form->setHtmlIdPrefix('something_');


    Doing this, you don't need to alter the form data you pass to $form->addValues to add your prefix. It will all be done automatically.



    The id prefix can be different for each tab if you have multiple tabs.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Jun 14 at 11:24









    Andhi Irawan

    4561 gold badge8 silver badges20 bronze badges




    4561 gold badge8 silver badges20 bronze badges










    answered Nov 24 '15 at 8:43









    MariusMarius

    170k28 gold badges329 silver badges703 bronze badges




    170k28 gold badges329 silver badges703 bronze badges












    • Close. I already used "slider_content" as id because otherwise the whole "content" block turned into an editor :) The remaining "content" only determines the name, which is already modified by addFieldNameSuffix() to have a different name on each tab. setHtmlIdPrefix() sounds like a good idea, but all tabs are within one form. If you have a solution for using a different prefix in different fieldsets of the same form, I'll happily accept the answer.

      – Fabian Schmengler
      Nov 24 '15 at 8:49











    • @fschmengler. $form = new Varien_Data_Form(); in each tab. Then you will have different instances of Varien_Data_Form in each tab. This will work because the elements are moved via js in an other <form> anyway. The core does the same thing. Check this for example: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/… and this: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/…

      – Marius
      Nov 24 '15 at 9:02












    • Of course.. these are already separate Varien_Form instances. Thanks Marius, for the clean solution!

      – Fabian Schmengler
      Nov 24 '15 at 9:08

















    • Close. I already used "slider_content" as id because otherwise the whole "content" block turned into an editor :) The remaining "content" only determines the name, which is already modified by addFieldNameSuffix() to have a different name on each tab. setHtmlIdPrefix() sounds like a good idea, but all tabs are within one form. If you have a solution for using a different prefix in different fieldsets of the same form, I'll happily accept the answer.

      – Fabian Schmengler
      Nov 24 '15 at 8:49











    • @fschmengler. $form = new Varien_Data_Form(); in each tab. Then you will have different instances of Varien_Data_Form in each tab. This will work because the elements are moved via js in an other <form> anyway. The core does the same thing. Check this for example: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/… and this: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/…

      – Marius
      Nov 24 '15 at 9:02












    • Of course.. these are already separate Varien_Form instances. Thanks Marius, for the clean solution!

      – Fabian Schmengler
      Nov 24 '15 at 9:08
















    Close. I already used "slider_content" as id because otherwise the whole "content" block turned into an editor :) The remaining "content" only determines the name, which is already modified by addFieldNameSuffix() to have a different name on each tab. setHtmlIdPrefix() sounds like a good idea, but all tabs are within one form. If you have a solution for using a different prefix in different fieldsets of the same form, I'll happily accept the answer.

    – Fabian Schmengler
    Nov 24 '15 at 8:49





    Close. I already used "slider_content" as id because otherwise the whole "content" block turned into an editor :) The remaining "content" only determines the name, which is already modified by addFieldNameSuffix() to have a different name on each tab. setHtmlIdPrefix() sounds like a good idea, but all tabs are within one form. If you have a solution for using a different prefix in different fieldsets of the same form, I'll happily accept the answer.

    – Fabian Schmengler
    Nov 24 '15 at 8:49













    @fschmengler. $form = new Varien_Data_Form(); in each tab. Then you will have different instances of Varien_Data_Form in each tab. This will work because the elements are moved via js in an other <form> anyway. The core does the same thing. Check this for example: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/… and this: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/…

    – Marius
    Nov 24 '15 at 9:02






    @fschmengler. $form = new Varien_Data_Form(); in each tab. Then you will have different instances of Varien_Data_Form in each tab. This will work because the elements are moved via js in an other <form> anyway. The core does the same thing. Check this for example: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/… and this: github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/…

    – Marius
    Nov 24 '15 at 9:02














    Of course.. these are already separate Varien_Form instances. Thanks Marius, for the clean solution!

    – Fabian Schmengler
    Nov 24 '15 at 9:08





    Of course.. these are already separate Varien_Form instances. Thanks Marius, for the clean solution!

    – Fabian Schmengler
    Nov 24 '15 at 9:08













    1














    The form was on a tab widget and as soon as there were multiple tabs, the elements had duplicate ids, this is what broke the editor. I added a unique prefix $elementIdPrefix for each tab, this solved the issue:



    $fieldset->addField($elementIdPrefix . 'content', 'editor', array(
    'name' => 'content',
    'label' => $helper->__('Content text (top)'),
    'wysiwyg' => true,
    'config' => $wysiwygConfig,
    ));


    To still be able to populate the form with data from a model, which is done based on the element id, I used the following code to add data:



    $slideData = $this->_getCurrentSlide()->getData();
    $formData = array();
    foreach($slideData as $key => $value)
    $formData[$elementIdPrefix . $key] = $value;

    $form->addValues($formData);


    $this->_getCurrentSlide() returns the model, previously the code was just:



    $form->addValues($this->_getCurrentSlide());





    share|improve this answer



























      1














      The form was on a tab widget and as soon as there were multiple tabs, the elements had duplicate ids, this is what broke the editor. I added a unique prefix $elementIdPrefix for each tab, this solved the issue:



      $fieldset->addField($elementIdPrefix . 'content', 'editor', array(
      'name' => 'content',
      'label' => $helper->__('Content text (top)'),
      'wysiwyg' => true,
      'config' => $wysiwygConfig,
      ));


      To still be able to populate the form with data from a model, which is done based on the element id, I used the following code to add data:



      $slideData = $this->_getCurrentSlide()->getData();
      $formData = array();
      foreach($slideData as $key => $value)
      $formData[$elementIdPrefix . $key] = $value;

      $form->addValues($formData);


      $this->_getCurrentSlide() returns the model, previously the code was just:



      $form->addValues($this->_getCurrentSlide());





      share|improve this answer

























        1












        1








        1







        The form was on a tab widget and as soon as there were multiple tabs, the elements had duplicate ids, this is what broke the editor. I added a unique prefix $elementIdPrefix for each tab, this solved the issue:



        $fieldset->addField($elementIdPrefix . 'content', 'editor', array(
        'name' => 'content',
        'label' => $helper->__('Content text (top)'),
        'wysiwyg' => true,
        'config' => $wysiwygConfig,
        ));


        To still be able to populate the form with data from a model, which is done based on the element id, I used the following code to add data:



        $slideData = $this->_getCurrentSlide()->getData();
        $formData = array();
        foreach($slideData as $key => $value)
        $formData[$elementIdPrefix . $key] = $value;

        $form->addValues($formData);


        $this->_getCurrentSlide() returns the model, previously the code was just:



        $form->addValues($this->_getCurrentSlide());





        share|improve this answer













        The form was on a tab widget and as soon as there were multiple tabs, the elements had duplicate ids, this is what broke the editor. I added a unique prefix $elementIdPrefix for each tab, this solved the issue:



        $fieldset->addField($elementIdPrefix . 'content', 'editor', array(
        'name' => 'content',
        'label' => $helper->__('Content text (top)'),
        'wysiwyg' => true,
        'config' => $wysiwygConfig,
        ));


        To still be able to populate the form with data from a model, which is done based on the element id, I used the following code to add data:



        $slideData = $this->_getCurrentSlide()->getData();
        $formData = array();
        foreach($slideData as $key => $value)
        $formData[$elementIdPrefix . $key] = $value;

        $form->addValues($formData);


        $this->_getCurrentSlide() returns the model, previously the code was just:



        $form->addValues($this->_getCurrentSlide());






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 '15 at 8:08









        Fabian SchmenglerFabian Schmengler

        55.4k21 gold badges145 silver badges359 bronze badges




        55.4k21 gold badges145 silver badges359 bronze badges



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f91264%2fcustom-form-with-wysiwyg-element-no-content-update-and-show-hide-editor-but%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

            Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

            Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?