[Twisted-web] How to pass invisible values with annotate.TypedInterface

Matt Goodall matt at pollenation.net
Fri Dec 24 06:35:56 MST 2004

On Fri, 2004-12-24 at 00:35 -0800, Michael Wilson wrote:
> My forms are modeled after the examples in examples/customform.py, and
> I try and use this standard form definition in multiple places.
> In some cases, I would like to pass an invisible value with the form.
> I know of two ways to do this:
> 1. By adding arguments to the form URL (
> action="./freeform_post!!doSomething?myarg1=...")
> 2. By adding invisible fields to the form. 
> What's the best way to do this? 
> P.S. I've looked at the examples and the code, can't find the answer. 

The renderer annotate.String tests for a hidden attribute. You can use
that to include a hidden field, i.e. foo=annotate.String(hidden=True).
However, hidden fields are not often that useful; perhaps you could make
better use of the URL?

A common use of hidden form fields is to include some object id in the
form so that, when the form is posted, you get the id back again. If
that's why you want a hidden field then you should seriously look at
using a URL like "http://foo.com/news/1" instead of
"http://foo.com/news?id=1". Request parameters are not a good way to
identify resources, IMHO.

Of course, if you have a different use case for a hidden form field then
please post an example. Perhaps it's something that formless/webform
should support in a more obvious way.

Cheers, Matt

More information about the Twisted-web mailing list