#23: Add support for ValidationWarning
-----------------------------+------------------------------------
     Reporter:  adrian       |                    Owner:  jgeskens
         Type:  New feature  |                   Status:  assigned
    Component:  Forms        |                  Version:
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Accepted
    Has patch:  1            |      Needs documentation:  1
  Needs tests:  0            |  Patch needs improvement:  1
Easy pickings:  0            |                    UI/UX:  1
-----------------------------+------------------------------------

Comment (by sebleblanc):

 I do not think that such a feature is useful, as it can easily be
 implemented using standard Django machinery.

 Here is an example, supposing that I am writing a user register form,
 where the date of birth is optional, but I want to warn the user that they
 would miss on some functionality on my site:

   Full name
   Date of birth
     <hidden "Ignore warning" boolean field (default: False)>
   Email
   Password

 Let us say the user fills all the form but the DOB field. In my form
 validation, I raise "ValidationError" if the DOB field is empty, and when
 the form is returned to the user, I display the hidden field, along with
 an explanation, so that the user may dismiss the warning. If the form is
 validated again, and the date of birth is still missing, but the checkbox
 is True, I then accept the form as submitted.

 I think this construct can easily be wrapped in a form field mixin. The
 only use for a ValidationWarning exception (derived from ValidationError)
 is to make it easier on the form display to determine if the checkbox
 should be shown. However, I think that they should be handled as regular
 error.

 i.e. (e.g) This form is only valid if field `foo` does not contain Unicode
 characters, or if `foo` does contains Unicode and that field
 `foo_ignore_unicode_warning` is True.

 If it had to be implemented, I think that having
 `<field>_<reason>_warning` methods would work great.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23#comment:32>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.d536d100dfca1977b35b7a8c081b81f3%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to