1. Blaise Laflamme
  2. deform


Reed O'Brien  committed 061501b

add type_ arg to button to allow for reset input

  • Participants
  • Parent commits 729be84
  • Branches default

Comments (0)

Files changed (3)

File deform/form.py

View file
         whatever is passed as ``name``.  E.g. if ``name`` is passed as
         ``submit``, ``title`` will be ``Submit``.
+    type_
+        The value used as the type of button. The HTML spec supports 
+        ``submit``, ``reset`` and ``button``. Default: ``submit``. 
         The value used as the value of the button when rendered (the
         ``value`` attribute of the button or input tag resulting from
         a form rendering).  Default: same as ``name`` passed.
-    def __init__(self, name='submit', title=None, value=None):
+    def __init__(self, name='submit', title=None, type_='submit', value=None):
         if title is None:
             title = name.capitalize()
         if value is None:
             value = name
         self.name = name
         self.title = title
+        self.type_ = type_
         self.value = value

File deform/templates/form.pt

View file
-              type="submit"
+              type="${button.type_}"
               class="btnText submit"

File deform/tests/test_form.py

View file
         button = self._makeOne()
         self.assertEqual(button.title, 'Submit')
+    def test_ctor_type_None(self):
+        button = self._makeOne()
+        self.assertEqual(button.type_, 'submit')
     def test_ctor_value_None(self):
         button = self._makeOne()
         self.assertEqual(button.value, 'submit')
     def test_ctor(self):
-        button = self._makeOne(name='name', title='title', value='value')
+        button = self._makeOne(name='name', title='title', 
+                               type_='type', value='value')
         self.assertEqual(button.value, 'value')
         self.assertEqual(button.name, 'name')
         self.assertEqual(button.title, 'title')
+        self.assertEqual(button.type_, 'type')
 class TestRaw(unittest.TestCase):
     def _makeOne(self, val):