Fieldsets marked as collapsed should not be collapsed on errors
|Reported by:||Jonas von Poser||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Using newforms-admin, I edit a model field that's contained in a collapsible fieldset. If this field does not validate, for instance I input a character string in an IntegerField, the page gets redisplayed after submitting and an error gets shown next to the field. On the redisplayed edit page, the fieldset containing the error is collapsed again.
When a fieldset contains an error, it should not be collapsed so the error can be found easily. In fact, the comments in django/contrib/admin/media/js/admin/CollapsedFieldsets.js:22 say so: "Collapsing shouldn't apply in the case of error messages."
The bug is in djang/contrib/admin/media/js/CollapsedFieldsets.js in the function named "fieldset_has_errors". A loop checks for the CSS class "error", but the DIV displaying the error is currently marked with a class called "errors".
I've attached a patch that fixes this. Thank you for considering it.