I have a problem with inserting value to wysiwyg editor when editing item in collection. I have this code, but editor still remain null.

 $content = Mage::getModel('news/news')->load($this->getRequest()->getParam('id'));
                        $fieldset->addField('ContentText', 'editor', array(
                            'name'      => 'content',
                            'label'     => Mage::helper('news')->__('Content'),
                            'title'     => Mage::helper('news')->__('Content'),
                            'style'     => 'height:20em;width:70em;',
                            'config'    => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
                            'value'     => $content['content'],
                            'wysiwyg'   => true,
                            'required'  => true,

when i call


I get my requested value

  • check if you don't call $form->setValues() later in the code. That will override the value of your field. – Marius Apr 16 '14 at 8:17
  • Yes, that's the point - but when I add my editor field after calling '$form->setValues()' it will be the last element in form. Is there a way to set priority to render ? – user3245106 Apr 16 '14 at 8:21
  • Don't add the editor after $form->setValues(). Try using $form->addValues() instead and make sure that there is no content element in the array you pass as a parameter to addValues. – Marius Apr 16 '14 at 8:24
  • @Marius fancy adding an complete answer here ;) – David Manners May 27 '14 at 14:25
  • 1
    @DavidManners. Odd thing...I was just on this question, started to write an answer and your comment popped up. :) – Marius May 27 '14 at 14:27

Based on the comments... you can add in your code, after defining the form this

$form->setValues(array(...., 'content'=>$content['content']));  
$form->addValues(array(...., 'content'=>$content['content'])); 

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.