Permalink
Browse files

Implemented a fix for when too many classes are added to a form field…

… under certain conditions
  • Loading branch information...
1 parent 48cf2fb commit 8f74539791d0b9f0c0d7cc3ec0e63eec2e6f3bcb @pydanny pydanny committed May 7, 2010
Showing with 9 additions and 3 deletions.
  1. +9 −3 uni_form/templatetags/uni_form_field.py
@@ -16,9 +16,15 @@ def with_class(field):
class_name = field.field.widget.__class__.__name__.lower()
class_name = class_converter.get(class_name, class_name)
if "class" in field.field.widget.attrs:
- field.field.widget.attrs['class'] += " %s" % class_name
+ css_class = field.field.widget.attrs['class']
+ if field.field.widget.attrs['class'].find(class_name) == -1:
+ css_class += " %s" % (class_name,)
else:
- field.field.widget.attrs['class'] = class_name
- return unicode(field)
+ css_class = class_name
+
+ return field.as_widget(attrs={'class': css_class})
+
+
+

0 comments on commit 8f74539

Please sign in to comment.