Opened 8 years ago

Closed 8 years ago

#5835 closed (duplicate)

New CheckboxInput method breaks edit_inline validation

Reported by: Lllama Owned by: nobody
Component: Forms Version: newforms-admin
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


In [6613] a new method was added to the CheckboxInput widget (in django/newforms/

    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/ 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:
            # 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.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.

Change History (1)

comment:1 Changed 8 years ago by Øyvind Saltvik <oyvind@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate or #5828

Note: See TracTickets for help on using tickets.
Back to Top