Commits

Andriy Kornatskyy committed d2d7cac

Eliminate hidden input from checkbox widget

Comments (0)

Files changed (2)

src/wheezy/html/factory.py

             name="name">John</textarea>
 
         >>> user.accept.checkbox()  #doctest: +NORMALIZE_WHITESPACE
-        <input type="hidden" name="accept" /><input type="checkbox"
-            id="accept" value="1" name="accept" />
+        <input type="checkbox" id="accept" value="1" name="accept" />
 
         >>> user = widget(model, errors)  # widget builders are cached
         >>> user.model.accept = True
         >>> user.accept.checkbox()  #doctest: +NORMALIZE_WHITESPACE
-        <input type="hidden" name="accept" /><input checked="checked"
-            type="checkbox" id="accept" value="1" name="accept" />
+        <input checked="checked" type="checkbox" id="accept" value="1"
+            name="accept" />
 
         >>> user.favorite_color.label('Color:')
         <label for="favorite-color">Color:</label>
         <textarea class="error" rows="9" cols="40" id="name"
             name="name">John</textarea>
         >>> user.accept.checkbox()  #doctest: +NORMALIZE_WHITESPACE
-        <input type="hidden" name="accept" /><input checked="checked"
-            name="accept" type="checkbox" id="accept" value="1"
-            class="error" />
+        <input checked="checked" name="accept" type="checkbox" id="accept"
+            value="1" class="error" />
         >>> user.favorite_color.label('Color:')
         <label class="error" for="favorite-color">Color:</label>
 

src/wheezy/html/widgets.py

 def checkbox(name, checked, attrs):
     """
         >>> checkbox('accept', 'True', {})  #doctest: +NORMALIZE_WHITESPACE
-        <input type="hidden" name="accept" /><input checked="checked"
-            type="checkbox" id="accept" value="1" name="accept" />
+        <input checked="checked" type="checkbox" id="accept" value="1"
+            name="accept" />
         >>> checkbox('accept', 'False', {})  #doctest: +NORMALIZE_WHITESPACE
-        <input type="hidden" name="accept" /><input type="checkbox"
-            id="accept" value="1" name="accept" />
+        <input type="checkbox" id="accept" value="1" name="accept" />
 
         >>> checkbox('accept', 'True',
         ...         attrs={'class': 'b'})  #doctest: +NORMALIZE_WHITESPACE
-        <input type="hidden" name="accept" /><input checked="checked"
-            name="accept" type="checkbox" id="accept" value="1" class="b" />
+        <input checked="checked" name="accept" type="checkbox" id="accept"
+            value="1" class="b" />
      """
     tag_attrs = {
             'id': id(name),
         tag_attrs['checked'] = 'checked'
     if attrs:
         tag_attrs.update(attrs)
-    return Fragment((
-            Tag('input', attrs={'name': name, 'type': 'hidden'}),
-            Tag('input', attrs=tag_attrs)
-    ))
+    return Tag('input', attrs=tag_attrs)
 
 
 def label(name, value, attrs):