Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Button name cannot have space in it #14

Merged
merged 2 commits into from

3 participants

@benzheren

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

@wichert

Can you add a test for this case?

@benzheren

added a test for this Button id fix

@mcdonc mcdonc merged commit 9bc5528 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 4, 2011
  1. @benzheren
Commits on May 20, 2011
  1. @benzheren

    add a test for button id fix

    benzheren authored
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 0 deletions.
  1. +3 −0  deform/form.py
  2. +5 −0 deform/tests/test_form.py
View
3  deform/form.py
@@ -1,3 +1,5 @@
+import re
+
from deform import widget
from deform import field
@@ -134,6 +136,7 @@ def __init__(self, name='submit', title=None, type='submit', value=None,
disabled=False):
if title is None:
title = name.capitalize()
+ name = re.sub(r'\s', '_', name)
if value is None:
value = name
self.name = name
View
5 deform/tests/test_form.py
@@ -66,6 +66,11 @@ def test_ctor_value_None(self):
button = self._makeOne()
self.assertEqual(button.value, 'submit')
+ def test_name_with_space(self):
+ button = self._makeOne(name="log\tin as a user")
+ self.assertEquals(button.name, 'log_in_as_a_user')
+ self.assertEquals(button.value, 'log_in_as_a_user')
+
def test_ctor(self):
button = self._makeOne(name='name', title='title',
type='type', value='value', disabled=True)
Something went wrong with that request. Please try again.