ZF-5387: If there is a validation error, the Editor doesn't show its value again.
Description
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; }
to:
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
Comments
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);
to:
$html = $this->textarea($textareaName, $value, $params, $attribs) .'<input' . $this->_htmlAttribs($hiddenAttribs) . $this->getClosingBracket();
Posted by K (karan.tandon@gmail.com) 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
Posted by K (karan.tandon@gmail.com) 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 (karan.tandon@gmail.com) on 2009-02-16T12:21:04.000+0000
SOLVED :)
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 (karan.tandon@gmail.com) 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.
_htmlAttribs($attribs) . '>' . $value . "\n"; return $html; } }