diff --git a/tests/test_widgets.py b/tests/test_widgets.py index 1ac0de3..5099184 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -494,6 +494,18 @@ class TestSpacer(WidgetTest): attrs = {} expected = """
""" + +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'} diff --git a/tw2/forms/widgets.py b/tw2/forms/widgets.py index 34c6ced..9834117 100755 --- a/tw2/forms/widgets.py +++ b/tw2/forms/widgets.py @@ -614,6 +614,9 @@ class Spacer(FormField): id = None label = None + def _validate(self, value, state=None): + return twc.EmptyField + class Label(twc.Widget): """