HiddenInput validation i18n trouble
|Reported by:||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
|Component:||Uncategorized → Forms|
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|
|Type:||Cleanup/optimization → Bug|