[Checkins] SVN: z3c.form/trunk/ Replace dots with hyphens when generating form id from its name.
Dan Korostelev
nadako at gmail.com
Tue Sep 1 07:00:24 EDT 2009
Log message for revision 103434:
Replace dots with hyphens when generating form id from its name.
Changed:
U z3c.form/trunk/CHANGES.txt
U z3c.form/trunk/src/z3c/form/form.py
U z3c.form/trunk/src/z3c/form/form.txt
-=-
Modified: z3c.form/trunk/CHANGES.txt
===================================================================
--- z3c.form/trunk/CHANGES.txt 2009-09-01 10:39:55 UTC (rev 103433)
+++ z3c.form/trunk/CHANGES.txt 2009-09-01 11:00:24 UTC (rev 103434)
@@ -5,6 +5,8 @@
Version 2.2.0 (unreleased)
--------------------------
+- Bug: Replace dots with hyphens when generating form id from its name.
+
- Refactored OutputChecker to its own module to allow using
``z3c.form.testing`` without needing to depend on ``lxml``
Modified: z3c.form/trunk/src/z3c/form/form.py
===================================================================
--- z3c.form/trunk/src/z3c/form/form.py 2009-09-01 10:39:55 UTC (rev 103433)
+++ z3c.form/trunk/src/z3c/form/form.py 2009-09-01 11:00:24 UTC (rev 103434)
@@ -193,7 +193,9 @@
"""See interfaces.IInputForm"""
return self.prefix.strip('.')
- id = name
+ @property
+ def id(self):
+ return self.name.replace('.', '-')
def updateActions(self):
self.actions = zope.component.getMultiAdapter(
Modified: z3c.form/trunk/src/z3c/form/form.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/form.txt 2009-09-01 10:39:55 UTC (rev 103433)
+++ z3c.form/trunk/src/z3c/form/form.txt 2009-09-01 11:00:24 UTC (rev 103434)
@@ -563,6 +563,14 @@
>>> addForm.name
'form'
+The id is computed from the name, replacing dots with hyphens. Let's set
+the prefix to something containing more than one final dot and check how
+it works.
+
+ >>> addForm.prefix = 'person.form.add.'
+ >>> addForm.id
+ 'person-form-add'
+
The template can then use those attributes, if it likes to.
In the examples previously we set the template manually. If no
More information about the checkins
mailing list