#5835: New CheckboxInput method breaks edit_inline validation
---------------------------+------------------------------------------------
Reporter: Lllama | Owner: nobody
Status: new | Component: django.newforms
Version: newforms-admin | Keywords:
Stage: Unreviewed | Has_patch: 0
---------------------------+------------------------------------------------
In [6613] a new method was added to the CheckboxInput widget (in
django/newforms/widgets.py)
{{{
def value_from_datadict(self, data, files, name):
if name not in data:
# A missing value means False because HTML form submission
does not
# send results for unselected checkboxes.
return False
return super(CheckboxInput, self).value_from_datadict(data, files,
name)
}}}
With this method any blank edit_inline objects in newforms-admin will
generate errors, with each field (other than the delete checkbox) saying
that it is required. (Changing the return value from 'False' to 'None'
will correct the error.) Using this I tracked down the calls to
value_from_datadict to django/newforms/forms.py. The is_empty() method:
{{{
def is_empty(self, exceptions=None):
"""
Returns True if this form has been bound and all fields that
aren't
listed in exceptions are empty.
"""
# TODO: This could probably use some optimization
exceptions = exceptions or []
for name, field in self.fields.items():
if name in exceptions:
continue
# value_from_datadict() gets the data from the dictionary.
# Each widget type knows how to retrieve its own data, because
some
# widgets split data over several HTML fields.
value = field.widget.value_from_datadict(self.data,
self.files, self.add_prefix(name))
# HACK: ['', ''] and [None, None] deal with
SplitDateTimeWidget. This should be more robust.
if value not in (None, '', ['', ''], [None, None]):
return False
return True
}}}
contains the HACK line. Adding 'False' to the tuple in the 'if' statement
again causes the error to disappear.
I'm guessing that this will only appear in newforms-admin as that's where
we get the checkboxes for deleting.
--
Ticket URL: <http://code.djangoproject.com/ticket/5835>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---