Ok, here's the diff (with context so you should be able to use this with patch). Commentary to follow.
$ cvs diff -c message-post.tcl
Index: message-post.tcl
===================================================================
RCS file: /usr/local/cvsroot/bp/packages/forums/www/message-post.tcl,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 message-post.tcl
*** message-post.tcl 15 Apr 2003 18:45:43 -0000 1.1.1.1
--- message-post.tcl 25 Aug 2003 17:54:22 -0000
***************
*** 38,63 ****
-html {size 60} \
-validate { {expr ![empty_string_p [string trim $value]]} {Please enter a subject} }
! # 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 \
-label Body \
! -datatype text \
! -widget textarea \
-html {rows 20 cols 60 wrap soft} \
-validate {
empty {expr ![empty_string_p [string trim $value]]} {Please enter a message}
- html { expr {( [string match [set l_html_p [ns_queryget html_p f]] "t"] && [empty_string_p [set v_message [ad_quotehtml [ad_html_security_check $value]]]] ) || [string match $l_html_p "f"] } }
- {}
}
element create message html_p \
-label Format \
-datatype text \
! -widget radio \
! -value $html_p \
! -options {{text f} {html t}}
element create message parent_id \
-label "parent ID" \
--- 38,58 ----
-html {size 60} \
-validate { {expr ![empty_string_p [string trim $value]]} {Please enter a subject} }
! element create message message_body \
-label Body \
! -datatype richtext \
! -widget richtext \
-html {rows 20 cols 60 wrap soft} \
-validate {
empty {expr ![empty_string_p [string trim $value]]} {Please enter a message}
}
+ # dummy for now - need to go back and remove html_p entirely
element create message html_p \
-label Format \
-datatype text \
! -widget hidden \
! -value 't'
element create message parent_id \
-label "parent ID" \
***************
*** 93,106 ****
if {[form is_valid message]} {
form get_values message \
! message_id forum_id parent_id subject content html_p confirm_p subscribe_p
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 message(html_p) $html_p
set message(subject) [ad_quotehtml $subject]
--- 88,103 ----
if {[form is_valid message]} {
form get_values message \
! 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 exported_vars [export_form_vars message_id forum_id parent_id subject html_p confirm_p message_body]
set message(html_p) $html_p
set message(subject) [ad_quotehtml $subject]
This is (I think) the smallest set of changes I can make. html_p is obviously not relevant anymore but we're just passing it around.
So here's what I've done:
- changed the textarea widget to richtext and renamed it to message_body
- turned html_p into an ignored hidden field (temporarily, will get rid of it after I get this working)
- set the value of content from $message_body
The result of this is that the format is showing up in the text area following the actual content, and the format is set to the empty string which causes form validation to bomb.
What seems to be going on (and confirmed with ns_log statements) is that $message_body is still a list going into the confirm page, but that's lost when it is passed along to the final run through message-post, where the actual insert is supposed to take place.
The next thing I tried was adding message_body to ad_page_contract and using a validation block to split up the string. However, ns_log statements here showed a new problem. The value of message_body when coming into the confirm page doesn't contain the format - it's just the text the user typed into the widget. So using this method the format is lost entirely.
So, to summarize:
message_body is turned into a string when it is passed through the confirm page in a hidden variable. The only way to get at the string and split it up before form validation happens for the insert step seems to be to grab it via ad_page_contract, but if I do that for one page I have to do it for all, and this does not work when going into the confirm page because (I'm guessing) "form get_values" is calling a richtext widget proc to get the value ad_page_contract isn't.
Whew. I hope that was somewhat clear. :)