Commits

Anonymous committed 6e7d694

set magic ID attribute in ``hidden`` helper

Comments (0)

Files changed (3)

 * webhelpers.html:
   - New ``HTML.cdata()`` method for producing "<!![CDATA[ ... ]]>" sections.
 * webhelpers.html.tags:
+  - Set magic ID attribute in ``hidden`` helper to match behavior of the other
+    tag helpers.
   - ``image()`` can now calculate the width and height automatically
     from an image file, using either the PIL algorithm or the pure Python
     algorithm in ``webhelpers.media``. It also logs the dimensions to the

tests/test_tags.py

     def test_hidden_field(self):
         eq_(
             hidden("id", 3),
-            u'<input name="id" type="hidden" value="3" />'
+            u'<input id="id" name="id" type="hidden" value="3" />'
         )
 
     def test_hidden_field_alt(self):
         eq_(
             hidden("id", '3'),
-            u'<input name="id" type="hidden" value="3" />'
+            u'<input id="id" name="id" type="hidden" value="3" />'
         )
 
     def test_password_field(self):

webhelpers/html/tags.py

     return HTML.input(**attrs)
 
 
-def hidden(name, value=None, **attrs):
+def hidden(name, value=None, id=None, **attrs):
     """Create a hidden field.
     """
     _set_input_attrs(attrs, "hidden", name, value)
+    _set_id_attr(attrs, id, name)
     return HTML.input(**attrs)