Issues

ZF-10516: Empty Zend_Dojo_Form_Element_Editor returns <br _moz_editor_bogus_node="TRUE" />

Description

When submitting empty form. The value of the field created by Zend_Dojo_Form_Element_Editor instead of being empty contains the value:

I found a solution here: http://journaldeguillaume.blogspot.com/2010/02/… It's as simple as adding filter to editor:

->setFilters(array('StringTrim', array('PregReplace',array('#
#i','')) ))

But I guess this bug should be solved anyway. Regards, Greg

Firefox 3.6.10

it's similar to the bug: http://zendframework.com/issues/browse/ZF-8707 but i'm not sure if these are the same things as the author seems to focus on another thing.

Comments

I've been looking into this for a while now, looks like Firefox adds that BR tag on it's own. Googling/IRCing didn't help. Same issue also appears/appeared in editors like CKEditor and FCKEditor.

The following code snippet/patch shows how we could fix this, but this looks hacky/dirty. Also it breaks one test ({{testHelperShouldCreateJavascriptToConnectEditorToHiddenValue}}); that test tests for the line which is edited/deleted in the patch bellow.


--- library/Zend/Dojo/View/Helper/Editor.php    (revision 23865)
+++ library/Zend/Dojo/View/Helper/Editor.php    (working copy)
@@ -178,7 +178,11 @@
function() {
     var form = zend.findParentForm(dojo.byId('$hiddenId'));
     dojo.connect(form, 'submit', function(e) {
-        dojo.byId('$hiddenId').value = dijit.byId('$editorId').getValue(false);
+        var value = dijit.byId('$editorId').getValue(false);
+        if(dojo.isFF) {
+            value = value.replace(/
/, ''); + } + dojo.byId('$hiddenId').value = value; });

Patch actually looks reasonable; the functionality that exists is largely due to inconsistencies in how browsers handle textarea submissions coming from non-textarea input.

I've applied the patch to trunk and the 1.11 release branch, along with test modifications.

Pull request for porting the patch in ZF2 is sent: https://github.com/zendframework/zf2/pull/306