ZF-5387: If there is a validation error, the Editor doesn't show its value again.

Issue Type: Bug Created: 2008-12-30T21:35:27.000+0000 Last Updated: 2010-01-21T04:53:38.000+0000 Status: Resolved Fix version(s): - 1.7.9 (11/Jan/10)

  • 1.8.5 (11/Jan/10)
  • 1.9.7 (11/Jan/10)

Reporter: Wenlong Wu (ezdevelop) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Dojo

Related issues: - ZF-8127



Here is the form: $this->addElement( 'TextBox', 'Title', array( 'label' => 'News Title:', 'required' => true, 'validators' => array( array('NotEmpty', true), ), ) );

$this->addElement( 'Editor', 'Content', array( 'label' => 'News Content:', 'required' => true, 'height' => '150px', 'focusOnLoad' => true, 'validators' => array( array('NotEmpty', true), ), ) );

If there is a validation error, the Editor will set the value to "Array".

Because there are two elements named "Content", see the following html code:

And the solution is change the textarea element's id and name.

Open the Zend/Dojo/View/Helper/Editor.php: change the following code: protected function _normalizeEditorName($name) { if ('[]' == substr($name, -2)) { $name = substr($name, 0, strlen($name) - 2); $name .= '[Editor][]'; } else { $name .= '[Editor]'; } return $name; }


protected function _normalizeEditorName($name) { if ('[]' == substr($name, -2)) { $name = substr($name, 0, strlen($name) - 2); $name .= '-Editor[]'; } else { $name .= '-Editor'; } return $name; }

Hope that helps.

Regard, Justin


Posted by Wenlong Wu (ezdevelop) on 2008-12-30T21:39:53.000+0000

Another solution is: Open the Zend/Dojo/View/Helper/Editor.php file:

change the following code: $html = '<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket() . $this->textarea($textareaName, $value, $params, $attribs);


$html = $this->textarea($textareaName, $value, $params, $attribs) .'<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket();

Posted by K ( on 2009-02-16T00:05:01.000+0000

Neither of the solutions work.

I am facing the same problem and am unable to capture the value type inside Editor.

If I hard code the value, like to 'something' below, then the server is able to capture the value correctly, on a valid post. using the following code: $form->editortab->getValue('content')

################### DOJO EDITOR ELEMENT
            'label'         => 'Content',
            'inheritWidth'  => 'true',
            'height'        => '230px',
            'width'         => '200px',
            'focusOnLoad'   => true,
            'required'      => $required,
            'value'         => 'some',


Posted by K ( on 2009-02-16T08:24:47.000+0000

Forgot to mention that when I hard-code, the value captured is only the text that I hard-coded (i.e. 'something') irrespective of what is actually typed on the UI

Posted by K ( on 2009-02-16T12:21:04.000+0000


To make Zend Dojo Editor work do following to .../Zend/Dojo/View/Helper/Dijit.php

1- Inside _createGetParentFormFunction() return elementNode.domNode; instead of return elementNode;

Posted by K ( on 2009-02-22T12:28:00.000+0000

However this solution only works for Firefox and not with the creepy Internet Explorer and the new kid called Google Crome


Posted by Vladimir Razuvaev (vladar) on 2010-01-02T17:13:41.000+0000

This issue appears because "textarea" tag is used as base for editor. Dojo doesn't recommend this for several reasons (including XSS vulnerability). It is much better to use "div" tag as a base for editor.

Here is a helper subclass, which replaces "textarea" tag to "div". Solution automatically fixes this bug and several other issues caused by same reason.

<pre class="highlight">
class MyEditor extends Zend_Dojo_View_Helper_Editor
    public function textarea($id, $value = null, array $params = array(), array $attribs = array())
        // it is a trivial copy-paste of Zend_Dojo_View_Helper_Textarea::textarea method
        // with replaced "textarea" tag to "div"

        if (!array_key_exists('id', $attribs)) {
            $attribs['id']    = $id;
        $attribs['name']  = $id;
        $attribs['type']  = $this->_elementType;

        $attribs = $this->_prepareDijit($attribs, $params, 'textarea');

        $html = '

_htmlAttribs($attribs) . '>'
              . $value
              . "


        return $html;

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.