Permalink
Browse files

fixed bug when re-showing checkboxes - widget failed on requesting ch…

…eckbox value
  • Loading branch information...
1 parent 292432e commit a07c112ead9a5cfae398fa3286fcdea711d93b04 Tim Parkin committed Jan 5, 2009
@@ -2,7 +2,6 @@
README
TODO
nose.sh
-setup.cfg
setup.py
docs-build/Makefile
docs-build/conf.py
View
@@ -129,7 +129,7 @@ def value(self):
"""Convert the request_data to a value object for the form or None."""
if '*' in self.name:
return ['']
- return self.form.request_data[self.name]
+ return self.form.request_data.get(self.name,None)
@property
@@ -1,7 +1,7 @@
<%inherit file="Field.html"/>
<%page args="field" />
<%
- if len(field.value) > 0 and field.value[0] == 'True':
+ if field.value is not None and len(field.value) > 0 and field.value[0] == 'True':
checked = 'checked="checked"'
else:
checked = ''
@@ -276,6 +276,42 @@ def functest_SimpleDecimal(self, sel):
+def RequiredStringAndCheckbox():
+ """
+ Testing that a checkbox is working properly when another required field is missing
+ """
+ schema = schemaish.Structure()
+ schema.add('myString', schemaish.String(validator=validatish.Required()))
+ schema.add('myBoolean', schemaish.Boolean())
+ form = formish.Form(schema, 'form')
+ form['myBoolean'].widget=formish.Checkbox()
+ return form
+
+def functest_RequiredStringAndCheckbox(self, sel):
+ sel.open("/RequiredStringAndCheckbox")
+
+ sel.click("form-action-submit")
+ sel.wait_for_page_to_load("30000")
+ try: self.failUnless(sel.is_text_present("is required"))
+ except AssertionError, e: self.verificationErrors.append(str(e))
+
+ sel.type("form-myString", "anything")
+ sel.click("form-action-submit")
+ sel.wait_for_page_to_load("30000")
+ try: self.failUnless(sel.is_text_present("{'myBoolean': False, 'myString': u'anything'}"))
+ except AssertionError, e: self.verificationErrors.append(str(e))
+
+ sel.type("form-myString", "anythingelse")
+ sel.click("form-myBoolean")
+ sel.click("form-action-submit")
+ sel.wait_for_page_to_load("30000")
+ try: self.failUnless(sel.is_text_present("{'myBoolean': True, 'myString': u'anythingelse'}"))
+ except AssertionError, e: self.verificationErrors.append(str(e))
+
+
+ return
+
+
def SimpleFile():
"""
A simple form with a single integer field
View
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os, glob
-version = '0.5'
+version = '0.5.1'
setup(name='formish',
version=version,

0 comments on commit a07c112

Please sign in to comment.