Author: ianb
Date: 2006-09-25 12:00:34 -0600 (Mon, 25 Sep 2006)
New Revision: 1945

Modified:
   FormEncode/trunk/docs/htmlfill.txt
   FormEncode/trunk/docs/news.txt
   FormEncode/trunk/formencode/htmlfill.py
Log:
Added form:iferror name='not something'

Modified: FormEncode/trunk/docs/htmlfill.txt
===================================================================
--- FormEncode/trunk/docs/htmlfill.txt  2006-09-25 17:54:07 UTC (rev 1944)
+++ FormEncode/trunk/docs/htmlfill.txt  2006-09-25 18:00:34 UTC (rev 1945)
@@ -54,7 +54,9 @@
     formatter (``"default"`` if no ``format`` attribute is given).
 ``<form:iferror name="field_name">...</form:iferror>``:
     If the named field doesn't have an error, everything between the
-    tags will be eliminated.
+    tags will be eliminated.  Use ``name="not field_name"`` to invert
+    the behavior (i.e., include text only if there are no errors for
+    the field).
 
 Formatters are functions that take the error text as a single
 argument.  (In the future they may take extra arguments as well.)

Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt      2006-09-25 17:54:07 UTC (rev 1944)
+++ FormEncode/trunk/docs/news.txt      2006-09-25 18:00:34 UTC (rev 1945)
@@ -15,6 +15,9 @@
   cause it to use ``datetime.time`` objects instead of tuples.  It was
   previously able to consume but not produce these objects.
 
+* Added ``<form:iferror name="not field_name">`` when you want to
+  include text only when a field has no errors.
+
 0.5.1
 -----
 

Modified: FormEncode/trunk/formencode/htmlfill.py
===================================================================
--- FormEncode/trunk/formencode/htmlfill.py     2006-09-25 17:54:07 UTC (rev 
1944)
+++ FormEncode/trunk/formencode/htmlfill.py     2006-09-25 18:00:34 UTC (rev 
1945)
@@ -282,9 +282,16 @@
 
     def handle_iferror(self, attrs):
         name = self.get_attr(attrs, 'name')
+        notted = False
+        if name.startswith('not '):
+            notted = True
+            name = name.split(None, 1)[1]
         assert name, "Name attribute in <iferror> required (%s)" % 
self.getpos()
         self.in_error = name
-        if not self.errors.get(name):
+        ok = self.errors.get(name)
+        if notted:
+            ok = not ok
+        if not ok:
             self.skip_error = True
         self.skip_next = True
 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FormEncode-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-cvs

Reply via email to