#15511 closed New feature (fixed)
MultiValueField should allow subfield requirement
Reported by: | Jeremy Dunck | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | timograham@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Example:
class PhoneFIeld(MultiValueField): def __init__(self, **kwargs): super(PhoneField).__init__(self, fields=( USPhoneNumberField(required=True), forms.CharField(error_messages={'invalid': u'Extension must be numeric'}, required=False), ), required=True)
This would require a change to .clean so that all subfields which were marked required to be filled in, but any non-required subfield would not be required.
Currently, subfield required's are forced to False, and a required at the MultiValueField level means all subfields are required.
Change History (12)
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:3 by , 13 years ago
UI/UX: | unset |
---|
comment:5 by , 12 years ago
Has patch: | set |
---|---|
Version: | 1.2 → master |
I have opened a PR with backwards compatible fix, tests and docs.
comment:6 by , 12 years ago
This also refs #13342 which was closed as wontfix by russellm who accepted this ticket. Presumably this ticket now includes sufficient detail.
comment:7 by , 11 years ago
Cc: | added |
---|---|
Patch needs improvement: | set |
PR needs to be rebased to master.
comment:9 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:10 by , 11 years ago
Just a quick clarification: will this fix make it into the final Django 1.6 release?
comment:11 by , 11 years ago
No, if you look at the commit you'll see it's been added to the release notes for 1.7.
comment:12 by , 11 years ago
After a significant amount of effort, I have succeeded in backporting this fix to Django 1.5.2. Unfortunately, it wasn't possible to backport this fix (#15511) without also backporting #17051. So, here is a patch that combines the fix for both bugs:
https://gist.github.com/nathan-osman/6347178
I ran the test suite after applying the patch and it seemed to pass without any failures.
Change UI/UX from NULL to False.