1

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

die($content['content']);

I get my requested value

5
  • check if you don't call $form->setValues() later in the code. That will override the value of your field.
    – Marius
    Apr 16, 2014 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 ? Apr 16, 2014 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, 2014 at 8:24
  • @Marius fancy adding an complete answer here ;) May 27, 2014 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, 2014 at 14:27

1 Answer 1

2

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.