[Checkins] SVN: z3c.form/trunk/src/z3c/form/hint. Cover the case when field doesn't have a description.

Dan Korostelev nadako at gmail.com
Mon Feb 9 21:57:51 EST 2009


Log message for revision 96361:
  Cover the case when field doesn't have a description.

Changed:
  U   z3c.form/trunk/src/z3c/form/hint.py
  U   z3c.form/trunk/src/z3c/form/hint.txt

-=-
Modified: z3c.form/trunk/src/z3c/form/hint.py
===================================================================
--- z3c.form/trunk/src/z3c/form/hint.py	2009-02-10 02:43:09 UTC (rev 96360)
+++ z3c.form/trunk/src/z3c/form/hint.py	2009-02-10 02:57:51 UTC (rev 96361)
@@ -43,6 +43,3 @@
             return self.field.description
         # None avoids rendering in templates
         return None
-
-    def __repr__(self):
-        return '<%s %r>' % (self.__class__.__name__, self.__name__)

Modified: z3c.form/trunk/src/z3c/form/hint.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/hint.txt	2009-02-10 02:43:09 UTC (rev 96360)
+++ z3c.form/trunk/src/z3c/form/hint.txt	2009-02-10 02:57:51 UTC (rev 96361)
@@ -31,11 +31,15 @@
   ...     textLine = zope.schema.TextLine(
   ...         title=u'Title',
   ...         description=u'A TextLine description')
+  ...
+  ...     anotherLine = zope.schema.TextLine(
+  ...         title=u'Other')
 
   >>> class Content(object):
   ...     zope.interface.implements(IContent)
   ...
   ...     textLine = None
+  ...     otherLine = None
   ...
   >>> content = Content()
 
@@ -47,7 +51,7 @@
 
   >>> hintForm = HintForm(content, request)
 
-As you can see, there is no title value set for our widget:
+As you can see, there is no title value set for our widgets:
 
   >>> hintForm.update()
   >>> print hintForm.widgets['textLine'].render()
@@ -56,6 +60,12 @@
          class="text-widget required textline-field"
          value="" type="text" />
 
+  >>> print hintForm.widgets['anotherLine'].render()
+  <input id="form-widgets-anotherLine"
+         name="form.widgets.anotherLine"
+         class="text-widget required textline-field"
+         value="" type="text" />
+
 Let's configure our IValue ``hint`` adapter:
 
   >>> from z3c.form.hint import FieldDescriptionAsHint
@@ -72,12 +82,20 @@
          title="A TextLine description" value=""
          type="text" />
 
+If the field has no description as it is with the second one, no "title"
+will be set for the widget:
 
+  >>> print hintForm.widgets['anotherLine'].render()
+  <input id="form-widgets-anotherLine"
+         name="form.widgets.anotherLine"
+         class="text-widget required textline-field"
+         value="" type="text" />
+
 Check all fields
 ----------------
 
 Just to make sure that all the widgets are handled correctly, we will
-go trhough each of them. This sample can be useful if you need to
+go through all of them. This sample can be useful if you need to
 implement a JavaScript based hint concept:
 
   >>> import datetime



More information about the Checkins mailing list