[Twisted-web] Q: Hidden field in TypedInterface?
Donovan Preston
twisted-web@twistedmatrix.com
Tue, 16 Dec 2003 13:39:50 -0500
On Dec 16, 2003, at 1:19 PM, Samuel Reynolds wrote:
> In a formless.TypedInterface, how does one specify a "hidden"
> parameter (i.e., force generation of a 'hidden' input widget in the
> generated form)?
>
> E.g., in :
> class IMyProxy(formless.TypedInterface):
> class PropertyGroup(formless.TypedInterface):
> id = formless.Integer()
> subject = formless.String()
> How to make id become a hidden field
> <input type='hidden' value ='...' name='id' />
> ?
It looks like you can't right now, although you used to be able to in
the older formless and formmethod. I'll probably add it, but I'd like
to think a bit about the right way to do it. I can think of two
methods:
class IMyProxy(TypedInterface):
id = formless.Hidden()
or
class IMyProxy(TypedInterface):
id = formless.Integer(hidden=True)
I think the former makes more sense, at least when it comes to html,
but it also discards information about which Typed.coerce method to
use. I would really like to know what you were planning to do with this
invisible field. Right now, I can see three ways to fill the invisible
field with your python code. The first is simply to have an 'id'
attribute on your configurable which implements IMyProxy. This id
attribute will be used to fill the field. The second is to pass a
default value (which will always be the value that is used...) like so:
Integer(default=5). The third is to get the IFormDefaults adapter
around the request, and call setDefault with the fully-qualified key of
the form field.
If you were planning on filling this field using javascript on the
client, that is a different matter entirely.
Can you give me a bit more information about what you are trying to do,
and how you would *like* to accomplish it?
dp