HiddenInput validation i18n trouble
|Reported by:||Evil Clay <clay.evil@…>||Owned by:||EmilStenstrom|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a model with ForeignKey filed and an ModelForm where i do set the Hidden Input widget for this filed.
I have these issues with required validation.
- if the field is empty i get an validation error that is only partially in my language.
- The error is printed out as non_field_error when i use form.as_p, but its not printed by the form.non_filed_error alone since the behavior is inconsistent.
I have tracked the issue to the module <django.forms.forms> line 152:
top_errors.extend([u'(Hidden field %s) %s' % (name, force_unicode(e)) for e in bf_errors])
To my (limited) knowledge i cannot solve the i18n by myself an easy way (dirty solution would by overriding the BaseForm class).
as for to second part i understand that this is an attempt to output the error somehow as i use form.as_xxx but when using hiddenInput on required filed, it is to be expected that i have to output the form myself to display the error on the page where i need to display it.
The best solution to solve both problems would probabbly be to loose the line 152.
Other solution is to loose the (Hidden filed %s part and ignore the inconstancy #2.
only workaround currently is not to use the form.as_xxx methods on an i18n project which implies that the line 152 sucks :)
Change History (3)
comment:1 Changed 4 years ago by aaugustin
- Component changed from Uncategorized to Forms
- Easy pickings set
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Cleanup/optimization to Bug
comment:2 Changed 4 years ago by EmilStenstrom
- Has patch set
- Owner changed from nobody to EmilStenstrom