Skip to content
This repository

Button name cannot have space in it #14

Merged
merged 2 commits into from almost 3 years ago

3 participants

Ben Hu Wichert Akkerman Chris McDonough
Ben Hu

For example, if the button name is Log in, then the DOM id of generated button is deformLog in, which is invalid.

Wichert Akkerman

Can you add a test for this case?

Ben Hu

added a test for this Button id fix

Chris McDonough mcdonc merged commit 9bc5528 into from June 23, 2011
Chris McDonough mcdonc closed this June 23, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
3  deform/form.py
... ...
@@ -1,3 +1,5 @@
  1
+import re
  2
+
1 3
 from deform import widget
2 4
 from deform import field
3 5
 
@@ -134,6 +136,7 @@ def __init__(self, name='submit', title=None, type='submit', value=None,
134 136
                  disabled=False):
135 137
         if title is None:
136 138
             title = name.capitalize()
  139
+        name = re.sub(r'\s', '_', name)
137 140
         if value is None:
138 141
             value = name
139 142
         self.name = name
5  deform/tests/test_form.py
@@ -66,6 +66,11 @@ def test_ctor_value_None(self):
66 66
         button = self._makeOne()
67 67
         self.assertEqual(button.value, 'submit')
68 68
 
  69
+    def test_name_with_space(self):
  70
+        button = self._makeOne(name="log\tin as a user")
  71
+        self.assertEquals(button.name, 'log_in_as_a_user')
  72
+        self.assertEquals(button.value, 'log_in_as_a_user')
  73
+    
69 74
     def test_ctor(self):
70 75
         button = self._makeOne(name='name', title='title', 
71 76
                                type='type', value='value', disabled=True)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.