Commits

pjenvey  committed 2ebcd0d

[svn] use '%s' % value instead of str(value) to handle unicode values, and
still handle ints
fixes #235

  • Participants
  • Parent commits ec199b1

Comments (0)

Files changed (4)

 WebHelpers ChangeLog
 
 0.3.1 (**svn**)
+* Fix radio_button and submit_to_remote not handling unicode values.
+  Fixes #235.
 * Added support for the defer attribute to javascript_include_tag. Suggested by
   s0undt3ch. Fixes #214.
 

File tests/test_form_tag.py

+# -*- coding: iso-8859-1 -*-
 from util import WebHelpersTestCase
 import unittest
 
             '<input checked="checked" id="num_people_5" name="num_people" type="radio" value="5" />'
         )
 
+        self.assertEqual(
+            radio_button("people", u'josé', checked=True),
+            '<input checked="checked" id="people_jos" name="people" type="radio" value="jos&#233;" />'
+        )
+
     def test_select(self):
         self.assertEqual(
             select("people", "<option>justin</option>"),

File webhelpers/rails/form_tag.py

     The id of the radio button will be set to the name + value with a _ in
     between to ensure its uniqueness.
     """
-    pretty_tag_value = re.sub(r'\s', "_", str(value))
+    pretty_tag_value = re.sub(r'\s', "_", '%s' % value)
     pretty_tag_value = re.sub(r'(?!-)\W', "", pretty_tag_value).lower()
     html_options = {'type': 'radio', 'name_': name, 'id': '%s_%s' % (name, pretty_tag_value), 'value': value}
     html_options.update(options)

File webhelpers/rails/prototype.py

     options['html']['type'] = 'button'
     options['html']['onclick'] = "%s; return false;" % remote_function(**options)
     options['html']['name_'] = name
-    options['html']['value'] = str(value)
+    options['html']['value'] = '%s' % value
     
     return tag("input", open=False, **options['html'])