Opened 19 years ago

Closed 17 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

Description

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 by Gary Wilson <gary.wilson@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Malcolm Tredinnick, 17 years ago

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