[Zope3-dev] bug setting value to None via edit form

Steve Alexander steve@cat-box.net
Sat, 12 Jul 2003 23:17:45 +0300


Garrett Smith wrote:
> The problem shows up clearly for Int field types: change a non None
> value (e.g. 12) to None by clearing the field and submitting the form.
> The field is updated, but the form displays the old value.
> 
> The problem is at line 174 of zope/app/form/utility in setUpWidget. It's
> currently:
> 
>     if value is not None and (force or not widget.haveData()):
>         widget.setData(value)
> 
>  I believe it should be:
> 
>     if force or not widget.haveData():
>         widget.setData(value)
> 
> None is a valid field value and widgets should be able to handle them.
> 
> I'd make the change (pending approval) but seemingly unrelated tests are
> blowing up...staying clear.

I think this is something that needs updating as part of the changes to 
make fields tell widgets what their prefered "missing" value is.

In the code you want to change, the "value is not None" should really be 
"value != field.missing_value". However, the rest of the work on this 
has not yet been done.

See this mail message for what should be done:

   http://mail.zope.org/pipermail/zope3-dev/2003-January/004855.html

The background and use-cases are discussed earlier in that thread.

   http://mail.zope.org/pipermail/zope3-dev/2003-January/004778.html
   http://mail.zope.org/pipermail/zope3-dev/2003-January/004810.html

--
Steve Alexander