#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 Changed 11 years ago by
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 Changed 11 years ago by
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:3 Changed 10 years ago by
UI/UX: | unset |
---|
comment:5 Changed 9 years ago by
Has patch: | set |
---|---|
Version: | 1.2 → master |
I have opened a PR with backwards compatible fix, tests and docs.
comment:6 Changed 9 years ago by
This also refs #13342 which was closed as wontfix by russellm who accepted this ticket. Presumably this ticket now includes sufficient detail.
comment:7 Changed 9 years ago by
Cc: | timograham@… added |
---|---|
Patch needs improvement: | set |
PR needs to be rebased to master.
comment:9 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:10 Changed 9 years ago by
Just a quick clarification: will this fix make it into the final Django 1.6 release?
comment:11 Changed 9 years ago by
No, if you look at the commit you'll see it's been added to the release notes for 1.7.
comment:12 Changed 9 years ago by
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.