You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Leszek Gawron <lg...@mobilebox.pl> on 2006/02/18 23:02:53 UTC

cforms + htmlarea bug

It looks like we have a bug concerning htmlarea widget in cforms. The 
problem is following htmlarea code:

if (textarea.form) {
	// we have a form, on submit get the HTMLArea content and
	// update original textarea.
	var f = textarea.form;
	if (typeof f.onsubmit == "function") {
		var funcref = f.onsubmit;
		if (typeof f.__msh_prevOnSubmit == "undefined") {
			f.__msh_prevOnSubmit = [];
		}
		f.__msh_prevOnSubmit.push(funcref);
	}
	f.onsubmit = function() {
		editor._textArea.value = editor.getHTML();
		var a = this.__msh_prevOnSubmit;
		// call previous submit methods if they were there.
		if (typeof a != "undefined") {
			for (var i in a) {
				a[i]();
			}
		}
	};
}

which means that form's original onsubmit handler is being wrapper with 
custom htmlarea code.

Problem: the code never gets executed as the form is not invoked from

<input type="submit" name="finish" value="finish"/>

but with <input type="button" onclick="forms_submitForm( 'finish' )"/> 
(or something similar).

Result: textarea is not populated with htmlare code - you get an empty 
textarea after submit.

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

Re: cforms + htmlarea bug

Posted by Jean-Baptiste Quenot <jb...@apache.org>.
* Leszek Gawron:

> Result: textarea is not populated with htmlare code - you get an empty textarea after submit.

Same here, if you look at the samples there is no CForms widget to
submit the form, just a plain old <input type="submit">
-- 
Jean-Baptiste Quenot
http://caraldi.com/jbq/

Re: cforms + htmlarea bug

Posted by Leszek Gawron <lg...@mobilebox.pl>.
hepabolu wrote:
> Hi,
> 
> AFAIK HTMLarea stopped being developed and Xinha has taken over. It's 
> supposed to be backwards compatible but has an active community. Maybe 
> replacing HTMLarea with Xinha already solves your problem:
> 
> http://xinha.python-hosting.com/
I might have expressed myself incorrectly. It is not the htmlarea 
problem - it is cforms that does not handle it's behaviour correctly.

Digging for the solution I found similar problem of xinha user (in other 
environment) which leads me to believe we would have the exact same 
problem with xinha.

-- 
Leszek Gawron                                      lgawron@mobilebox.pl
IT Manager                                         MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

Re: cforms + htmlarea bug

Posted by hepabolu <he...@gmail.com>.
Hi,

AFAIK HTMLarea stopped being developed and Xinha has taken over. It's 
supposed to be backwards compatible but has an active community. Maybe 
replacing HTMLarea with Xinha already solves your problem:

http://xinha.python-hosting.com/

HTH

Bye, Helma


Leszek Gawron wrote:
> It looks like we have a bug concerning htmlarea widget in cforms. The 
> problem is following htmlarea code:
> 
> if (textarea.form) {
>     // we have a form, on submit get the HTMLArea content and
>     // update original textarea.
>     var f = textarea.form;
>     if (typeof f.onsubmit == "function") {
>         var funcref = f.onsubmit;
>         if (typeof f.__msh_prevOnSubmit == "undefined") {
>             f.__msh_prevOnSubmit = [];
>         }
>         f.__msh_prevOnSubmit.push(funcref);
>     }
>     f.onsubmit = function() {
>         editor._textArea.value = editor.getHTML();
>         var a = this.__msh_prevOnSubmit;
>         // call previous submit methods if they were there.
>         if (typeof a != "undefined") {
>             for (var i in a) {
>                 a[i]();
>             }
>         }
>     };
> }
> 
> which means that form's original onsubmit handler is being wrapper with 
> custom htmlarea code.
> 
> Problem: the code never gets executed as the form is not invoked from
> 
> <input type="submit" name="finish" value="finish"/>
> 
> but with <input type="button" onclick="forms_submitForm( 'finish' )"/> 
> (or something similar).
> 
> Result: textarea is not populated with htmlare code - you get an empty 
> textarea after submit.
>