Skip to content

Commit

Permalink
Replace dots with hyphens when generating form id from its name.
Browse files Browse the repository at this point in the history
  • Loading branch information
nadako committed Sep 1, 2009
1 parent be66941 commit ed2bed8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -5,6 +5,8 @@ CHANGES
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``

Expand Down
4 changes: 3 additions & 1 deletion src/z3c/form/form.py
Expand Up @@ -193,7 +193,9 @@ def name(self):
"""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(
Expand Down
8 changes: 8 additions & 0 deletions src/z3c/form/form.txt
Expand Up @@ -563,6 +563,14 @@ trailing ".".
>>> 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
Expand Down

0 comments on commit ed2bed8

Please sign in to comment.