Forum OpenACS Development: Re: Using the richtext widget

Collapse
Posted by Lars Pind on
Janine,

I've now taken a look and found the problem.

When you export the value, you export the { body format } list as the value of element "message_body".

But if you look at the source behind the edit form with the richtext widget, you see that there are two widgets:

message_body is the textarea into which the text gets entered.

message_body.format is the select box which lets you pick the format.

If you export the values the same way, it works:

set exported_vars [export_vars -form { message_id forum_id parent_id subject html_p confirm_p { message_body $content} { message_body.format $format } }]

Here's a complete patch against the version I have running here:

Index: message-post.tcl
===================================================================
RCS file: /cvsroot/openacs-4/packages/forums/www/message-post.tcl,v
retrieving revision 1.13.2.6
diff -u -r1.13.2.6 message-post.tcl
--- message-post.tcl    24 Mar 2003 09:11:10 -0000      1.13.2.6
+++ message-post.tcl    1 Sep 2003 19:31:17 -0000
@@ -41,10 +41,10 @@
# we use ns_queryget to get the value of html_p because it won't be defined
# until the next element -DaveB

-element create message content \
+element create message message_body \
    -label Body \
-    -datatype text \
-    -widget textarea \
+    -datatype richtext \
+    -widget richtext \
    -html {rows 20 cols 60 wrap soft} \
    -validate {
        empty {expr ![empty_string_p [string trim $value]]} {Please enter a message}
@@ -55,8 +55,8 @@
element create message html_p \
    -label Format \
    -datatype text \
-    -widget radio \
-    -value $html_p \
+    -widget hidden \
+    -value "t" \
    -options {{text f} {html t}}

element create message parent_id \
@@ -93,14 +93,17 @@

if {[form is_valid message]} {
    form get_values message \
-        message_id forum_id parent_id subject content html_p confirm_p subscribe_p
+        message_id forum_id parent_id subject html_p confirm_p subscribe_p message_body
+
+    set content [template::util::richtext::get_property contents $message_body]
+    set format [template::util::richtext::get_property format $message_body]

    if {!$confirm_p} {
        forum::get -forum_id $forum_id -array forum

        set confirm_p 1
        set content [string trimright $content]
-        set exported_vars [export_form_vars message_id forum_id parent_id subject content html_p confirm_p]
+        set exported_vars [export_vars -form { message_id forum_id parent_id subject html_p confirm_p { message_body $content} { m\
essage_body.format $format } }]

        set message(html_p) $html_p
        set message(subject) [ad_quotehtml $subject]

----------

If you would provide a fix for this for 5.0, that would be awesome!

/Lars