Fix invalid error_messages on Regexfield (testapp customer/phonenumber)#211
Fix invalid error_messages on Regexfield (testapp customer/phonenumber)#211smallsam wants to merge 1 commit intojrief:releases/1.8from
Conversation
|
Could you please describe how to reproduce this error. |
|
Sure. If you run the testapp in the django-formset repo. If you visit: /default/customer If you fill out "something" in the Phone Number field you will see "Enter a valid value" as the client side error. This field is defined as below in This PR fixes the behaviour and instead displays the error_message defined in the widget. We would normally expect the "invalid" error_message to override the RegexValidator message. It appears the earlier PR (#94) added the if statement in the wrong place. This PR fixes the expected override behaviour where error_messages defined in the widget override those raised by any validators. This was the original behaviour of django-formset in earlier releases. |
|
This has been fixed in upcoming version 2.0. If you want to try it out, please checkout the branch https://github.com/jrief/django-formset/tree/ModelAdmin-support Thanks for reporting. |

In PR: https://github.com/jrief/django-formset/pull/94/files
the generation of client error messages broke and no longer reflects the behaviour of django form fields where the Field error_messages dict overrides those set on validators.
In particular the error code "invalid" was impacted, this fix should restore correct behaviour of the client side errors.
The testapp customer form, has a phone number field, this should fix the e2e field test for that field (which I believe is broken right now).