Zend Dojo Editor-Plugin by name editor not found

18 Nov

Few days back when I tried to use Dojo editor in my application, I was served with error “plugin by name editor not found”.
As it is my custom to work until and unless I find solution, so I tried hard and worked for few days. At the end hard work pay off and find the solution.
Nothing was wrong with my code, however I was using Zend Framework version 1.6, when I updated my version and dojo toolkit the following fancy dojo editor was displayed on my page.

Zend Dojo Editor

Zend Dojo Editor

class forms_SimpleForm extends Zend_Dojo_Form
{
public function __construct($options = null)
{
parent::__construct($options);

$editor=new Zend_Dojo_Form_Element_Editor(‘content’);
$editor->setLabel(‘Contents’);
$this->addElements(array(
$editor
));
}
}
?>

That’s it. Have fun.

12 Responses to “Zend Dojo Editor-Plugin by name editor not found”

  1. Ahsan Shahzad November 18, 2008 at 2:41 pm #

    realy awsome!
    thanks for posting this handy method to use Zend Dojo Editor,
    definately i’ll try it🙂

  2. Thang January 15, 2009 at 7:26 pm #

    Yes, I have the same problem and it’s solved when upgrading to ZF 1.7. But I don’t know how to get value from this form (I tried $form->getvalue(‘editorName’); but it’s empty)

  3. Faheem Abbas January 16, 2009 at 9:03 am #

    Try this one
    $values = $this->getRequest()->getParams();
    However keep in mind that this will return more result than u expect. so better to write
    Zend_Debug::dump($values);
    you will see the entire set of data returned.

  4. Thang January 19, 2009 at 7:45 am #

    I can get values from all other form elements except the editor (return empty).
    Here is debug values:
    rray
    ‘controller’ => string ‘admin’ (length=5)
    ‘action’ => string ‘post’ (length=4)
    ‘module’ => string ‘default’ (length=7)
    ‘title’ => string ‘testing fdsa’ (length=4)
    ‘header’ => string ‘tesing fwer’ (length=4)
    ‘main’ =>
    array
    ‘Editor’ => string ” (length=0)
    ‘security’ => string ‘0’ (length=1)
    ‘submit’ => string ‘Submit’ (length=6)

  5. Faheem Abbas January 19, 2009 at 9:05 am #

    This shouldn’t happen, and never happen with me.
    Better if you post your code. I’ll be able to see what is causing this bug.

  6. Thang January 19, 2009 at 9:24 am #

    @Abbas: Here is my code:
    class NewarticleForm extends Zend_Dojo_Form
    {
    public function init()
    {
    $form = new Zend_Dojo_Form();
    $form->setMethod(‘POST’);
    $form->setName(‘NewarticleForm’);

    //Title
    $this->addElement(‘text’,’title’,array(
    ‘label’ => ‘Title:’,
    ‘required’ => true,

    ‘filters’ => array(‘StringTrim’),
    ‘validator’ => array(‘Alnum’)

    ));

    //Header
    $this->addElement(‘Textarea’,
    ‘header’,
    array(
    ‘label’ => ‘Textarea’,
    ‘required’ => true,
    ‘style’ => ‘width: 400px; height: 100px’,
    ));

    //Main
    $this->addElement(‘editor’, ‘main’,
    array(
    ‘editActionInterval’ => 2,
    ‘focusOnLoad’ => true,
    ‘height’ => ‘250px’,
    ‘inheritWidth’ => true,
    ‘setName’ => ‘main’,
    // ‘value’ => ‘test’
    ));

    //Security
    $this->addElement(‘text’,’security’,array(
    ‘label’ => ‘Option:’,
    ‘required’ => true,
    ‘filters’ => array(‘StringTrim’),
    ‘validator’ => array(‘Alnum’),
    ‘value’ => ‘0’

    ));

    // add the submit button
    $this->addElement(‘submit’, ‘submit’, array(
    ‘label’ => ‘Submit’,
    ));

    $this->clearDecorators();
    $this->addDecorator(‘FormElements’)
    ->addDecorator(‘HtmlTag’, array(‘tag’ => ”))
    ->addDecorator(‘Form’);
    }
    }

  7. Faheem Abbas January 19, 2009 at 11:10 am #

    $form = new Zend_Dojo_Form();
    $form->setMethod(’POST’);
    $form->setName(’NewarticleForm’);

    Remove first line. no need of that when you Extend your class from Zend_Dojo_Form or Zend_Form.
    and replace
    $form->setMethod(’POST’);
    $form->setName(’NewarticleForm’);
    with
    $this->setMethod(’POST’);
    $this->setName(’NewarticleForm’);

  8. Thang January 20, 2009 at 2:34 am #

    Thanks Faheem.
    I found a valuable note in your entry: “when I updated my version and dojo toolkit”, so I updated the Dojo to version number 1.2.3. Now it works.

    Note for others: After doing above guideline from Faheem Abbas, the editor will return to an array, so to get editor’s value, add this line

    $values = $this->getRequest()->getParams();
    $editor = $values[‘your_own_name’][‘Editor’];

  9. Jean-Marc Rigade January 21, 2009 at 4:44 pm #

    Zend_Dojo_Form_Element_Editor dont work with Internet Explorer 7.
    Its impossible to type some characters in it…

  10. Godfrie February 25, 2009 at 11:00 pm #

    Zend_Dojo_Form_Element_Editor wont work for people who disable javascript either😦

  11. Godfrie February 25, 2009 at 11:31 pm #

    Ive just tried this but it doesn’t work – the content is still blank.


    $formData = $this->getRequest()->getParams();

    Zend_Debug::dump($formData);

    Gives:

    array(7) {
    ["controller"] => string(8) "comments"
    ["action"] => string(7) "comment"
    ["module"] => string(7) "default"
    ["id"] => string(2) "95"
    ["title"] => string(9) "Fancy editor"
    ["comment"] => string(0) "" string(6) "Submit"
    }

    The form class:

    class CommentForm extends Zend_Dojo_Form
    {
    public function __construct($options = null)
    {
    parent::__construct($options);
    $this->setName('comment');

    $id = new Zend_Form_Element_Hidden('id');
    $this->addElement($id);

    $title = $this->addElement('TextBox', 'title', array(
    'filters' => array('StringTrim', 'StripTags'),
    'validators' => array(
    'NotEmpty',
    array('StringLength', false, array(1, 128)),
    ),
    'required' => true,
    'label' => 'Title',
    ));

    $content = new Zend_Dojo_Form_Element_Editor('comment');
    $content->setLabel('Comment')
    ->setRequired(true)
    ->addPlugins(array('undo', '|', 'bold', 'italic'))
    ->setEditActionInterval(2)
    ->setFocusOnLoad(false);
    $this->addElement($content);

    /*
    $content = new Zend_Form_Element_Textarea('comment');
    $content->setLabel('Comment')
    ->setRequired(true)
    ->addFilter('StripTags')
    ->addFilter('StringTrim')
    ->addValidator('NotEmpty');
    */

    $submit = $this->addElement('SubmitButton', 'submit', array(
    'required' => false,
    'ignore' => true,
    'label' => 'Submit',
    ));

    $this->setDecorators(array(
    'FormElements',
    array('HtmlTag', array('tag' => 'dl', 'class' => 'bbcform')),
    array('Description', array('placement' => 'prepend')),
    'Form'
    ));
    }
    }

    Anyone got any ideas?

    G

  12. nitin March 27, 2009 at 6:31 am #

    i use this code but in my form content is look like just ordinary text area why?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: