[Framework-Team] Re: Re: The big 3.0 ;)

Geir Bækholt · Plone Solutions baekholt at plonesolutions.com
Sat Mar 24 10:04:50 UTC 2007

On 24. mar. 2007, at 00.13, Alec Mitchell wrote:

> It's a fundamental HTML form issue.  No matter what the name of the
> field (e.g. even if it has a ':boolean'), if the checkbox is not
> checked then the input is not included in the request (so the value
> won't be changed).  It may be possible to use a hidden field with a
> False value, so that something is always submitted.  IIRC Zope will
> interpret two fields with the same name as a list of values (even
> without ':list').  So a hidden field that is False and a checkbox that
> is checked will give [False, True] which will evaluate to True in a
> boolean context, but an unchecked checkbox and a hidden False value
> will just give the False value from the hidden field.  If that doesn't
> work, then I think js is the only way to do this without introspecting
> the schema to see what boolean fields may have been missing from the
> form.

Yes. of course the :default must be supplied or the checkbox will not  
be noticed by html.
I somehow took this for granted and didn't mention it (sorry. my  
oversight), but i see now in boolean.pt widget template in AT that it  
is not included.

Zope has its own built-in form typecast for this:

<input type="checkbox" name="foobar:boolean" value="True" />
<input type="hidden" name="foobar:boolean:default" value="" />

Works for all cases i can find.

I don't have the 10 minutes i need to actually check it into AT and  
test that it works TTW right now, but i'll try to get it done tonight  
unless someone beats me to it.


Geir Bækholt     ·    Managing Director     ·    Plone Solutions

Consulting · Training · Development ·  http://plonesolutions.com

More information about the Framework-Team mailing list