On Wed, 2007-11-28 at 07:12 -0800, Ryan K wrote: > I have a basic registration form for my site that has fields for a > postal code, state and a country. Since our site caters to > international users, I only want to require a state and postal code > only if the country is the United States. I have a clean_country > method in my form that raises a ValidationError if postal_code and > state are empty strings but the error message displays next to the > country field. How can I make the errors appear next to the proper > field even though another field's clean method is propagating the > ValidationError? I don't want to use clean() because the errors should > clearly be marked and not something generic at the top.
You can assign to form._errors directly if you want to do this. Just make sure you do it either after the automatic field cleaning for that field name has taken place of in your clean() method override, otherwise your changes will be nuked by the automatic cleaning. Also, ensure that you assign a django.newforms.ErrorList instance to the dictionary key there and not just a Python list; that will ensure that the ultimate display of the error messages comes out correctly. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---