Opened 9 years ago

Closed 8 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
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: UI/UX:

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

  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 8 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

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