Re: formfill strips all values

"Przemyslaw Wrzos" <przemyslaw.wrzos-NeEqHDZDq+K1Z/[email protected]> Wed, 17 Sep 2008 11:56:24 +1000
Newsgroups gmane.comp.python.formencode
Message-ID <[email protected]>
Actually, for checkboxes, htmlfill compares the value in the 'defaults'
dictionary against the 'value' attribute of the input checkbox element
to decide if the 'checked' attribute should be set. So you can tell it
to uncheck the box by explicitly setting the appropriate key in defaults
to None (or anything else that doesn't equal the value attribute).

Is there any other form field types that could cause a problem with
this?

In my case the desired functionality really belongs on the client side
(used interactively with JavaScript) and shouldn't be scattered around
in my controllers. The maximum functionality I think would be ok in the
controller would be to tell htmlfill to leave alone unspecified values
otherwise it all starts to turn into a mess.

Cheers,
Przemek

-----Original Message-----
From: Ian Bicking [mailto:[email protected]] 
Sent: Wednesday, 17 September 2008 3:49 AM
To: Przemyslaw Wrzos
Cc: formencode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [FE-discuss] formfill strips all values

Przemyslaw Wrzos wrote:
> I've just encountered an issue where formfill() strips the values of 
> fields for which I do not provide any values in the defaults parameter

> (specifically for a checkbox in my case). Is this behaviour 
> intentionally like that by design? Do I have any options to get around

> that? If not perhaps it would be a good idea to change this behaviour
by 
> default or at least provide an option which would allow it to change.

I don't see a way to distinguish between unset values in the values sent

to render, and actual values that are empty.  For instance, an unchecked

checkbox is just no value at all.

Can you put the defaults into the dictionary you pass into render?

-- 
Ian Bicking : [email protected] : http://blog.ianbicking.org

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/