[Zope] Passing a list through a form?

Casey Duncan cduncan@kaivo.com
Mon, 16 Apr 2001 09:02:39 -0600


Tony Tocco wrote:
> 
> I've been looking for the preferred way to send a list through a form to
> another DTML document.
> 
> What I'm trying to do is something like this.
> 
> <form name="jumpform" method="post" action="pg_errors">
>         <input type="hidden" name="f_errors:list" value="<dtml-var f_errors>">
> </form>
> 
> Where f_errors contains a list of strings which may contain characters
> (including >'s and "'s) which destroy this form quickly.  I have not been
> able to determine what format the value="" field should take in order for
> this form to send a list.  Can someone clarify how this value="" field
> should be created so that my calling document recieves data capable of being
> reconstructed into a list?
> 
> NOTE: jumpform is javascript submitted by a custom header.
> 
> Regards,
> ttocco

Zope has an html_quote feature which properly escapes any HTML
significant characters such as ">" by substituting their entity
equivilants. If you use the dtml entity syntax, you get html_quoting
thrown in for free, in normal dtml-var statements, you must specify it
specifically.

As for lists, the ":list" marshalling is used to creeate a list from
multiple form fields or multi-select lists. If you want to create a list
from a single text field, use ":tokens" or ":lines", which are space
delimited and newline delimited respectively. Your example could look
like:

<form name="jumpform" method="post" action="pg_errors">
     <input type="hidden" name="f_errors:tokens" 
            value="<dtml-if f_errors><dtml-var
expr="_.string.join(f_errors)" html_quote></dtml-if>">
</form>

Which would make a list out of a space delimited f_errors value, and
html_quote the value.
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>