Opened 17 years ago

Closed 16 years ago

#4405 closed (invalid)

MultiValueField does not allow sub-fields to be blank

Reported by: adurdin@… Owned by: Konrad Beiske
Component: Forms Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If even one of a MultiValueField's sub-fields is blank, a ValidationError is raised, even if that sub-field had required=False

In django/newforms/fields.py, line 530

            if self.required and field_value in EMPTY_VALUES:
                raise ValidationError(gettext(u'This field is required.'))

Line 530 should be changed to check the sub-field's required attribute:

            if field.required and field_value in EMPTY_VALUES:

Change History (5)

comment:1 by Jacob, 17 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Konrad Beiske <konrad@…>, 16 years ago

Owner: changed from nobody to anonymous
Status: newassigned

comment:3 by Konrad Beiske, 16 years ago

Owner: changed from anonymous to Konrad Beiske
Status: assignednew

comment:4 by Konrad Beiske, 16 years ago

Status: newassigned

comment:5 by Konrad Beiske, 16 years ago

Resolution: invalid
Status: assignedclosed

MultiValueField is currently made to completely ignore the required field setting of it's subfields. In fact it's init method sets all subfields as not required. It does allow subfields to be blank it self is allowed to be blank as well. Subclasses can allow some fields blank and some not in the compress function.

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