Skip to content

Commit

Permalink
Stop twf.Spacer from injecting None key in validated data.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed May 24, 2012
1 parent 8218360 commit 71b33b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,18 @@ class TestSpacer(WidgetTest):
attrs = {}
expected = """<div></div>"""


def test_spacer_validation():
""" Test that spacers don't inject None keys in validated data. """

class SomeForm(TableForm):
some_id = HiddenField
space = Spacer

data = SomeForm.validate({})
assert None not in data


class TestLabel(WidgetTest):
widget = Label
attrs = {'text':'something'}
Expand Down
3 changes: 3 additions & 0 deletions tw2/forms/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,9 @@ class Spacer(FormField):
id = None
label = None

def _validate(self, value, state=None):
return twc.EmptyField


class Label(twc.Widget):
"""
Expand Down

0 comments on commit 71b33b5

Please sign in to comment.