Forum OpenACS Development: Using noquote with ad_form and formtemplate

Is there a simple way to specify a widget to use noquote in ad_form?  I've a situation in which I need to edit multibyte characters retrieved from the database.

In the tcl file, I did something like:

ad_form -name some_form -form {
    note_id:key(acs_object_id_seq)
    {note:text(textarea),optional,nospell {label "Note"}}
}  -select_query {
    select note from info where note_id = :note_id
} -edit_data {
#...
}

In the adp file, I had something like:

<formtemplate id="some_form"></formtemplate>

What I got in the display textarea was a brunch of &#31649; &#29702; ....  Looking at the source revealed that the data was overquoted.  Any suggestion or pointer to get around this problem is much appreicated.  Thanks!

Collapse
Posted by Branimir Dolicki on
You probably ended up having things like '&#31649;' in your
database.  That can happen if your server doesn't send forms
with Content-Type=text/html; charset=utf-8.  When this heppens
the default is iso-8859-1.  If user types characters that
can't be represented in iso-8859-1, browsers (MSIE, but also
Mozilla) do something very, very stupid.  They convert the
characters to things like '&#31649;' and send them with
the form so they finally end up in your database.
Collapse
Posted by Tak-Hung Yu on
Branimir,

You're right. I changed the aolserver setting according to this thread. That does it. Thanks a lot!

Just out of curiosity, is there a way to change the setting for a particular page instead of the whole site?

Collapse
Posted by Joel Aufrecht on
These settings (with utf-8) are the default in the 5.1 config.tcl, by the way.
Collapse
Posted by Branimir Dolicki on
Hi,

Unfortunatelly is not possible to change this parameter per page.  When I needed it once I ended up writing my own thing to return the file and put the appropriate Content-Type header.  The place where this header is set is very, very low in AOLserver C code 😟

Collapse
Posted by Tom Jackson on

You might look into using ns_conn outputheaders, where you can set any header. I'm not sure if this might get reset after the tcl page is sourced or not, but it might allow you to do what you want. For instance, you might look at template::set_http_status, and see how that all works too.

Collapse
Posted by Branimir Dolicki on
Tom,

You are right:

ns_set put [ns_conn outputheaders] Content-Type "text/html; charset=yourcharset"

Will do the trick. I confused this with the case where I wanted to set the charset on some HTML pages sitting in the filesystem and output witn ns_returnfile.

Collapse
Posted by Mark Aufflick on
There is still a problem when you include a return url in a form - the &'s get overquoted into &amp; - not helpful