Opened 13 years ago

Closed 12 years ago

#609 closed defect (invalid)

When using validators.RequiredIfOtherFieldEquals with a Boolean field, it doesn't work the obvious way

Reported by: slashzero Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When using the RequiredIfOtherFieldEquals on a Boolean field, the form field want's 'on' for True instead of True
For instance

    blog_url = meta.URLField(verbose_name="Blog url",null=True,blank=True,
                             validator_list=[validators.RequiredIfOtherFieldEquals("has_blog",True,"You must provide a Blog url")])

doesn't work where as:

    blog_url = meta.URLField(verbose_name="Blog url",null=True,blank=True,
                             validator_list=[validators.RequiredIfOtherFieldEquals("has_blog",'on',"You must provide a Blog url")])

does. This seems a little counter-intuitive

Change History (2)

comment:1 Changed 12 years ago by Gary Wilson <gary.wilson@…>

Triage Stage: UnreviewedDesign decision needed

comment:2 Changed 12 years ago by Malcolm Tredinnick

Resolution: invalid
Status: newclosed

Validators work on unprocessed HTML input. A checkbox from an HTML form comes in "on" and not-"on" varieties, not True and False. So the validator is working correctly.

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