Commits

Anonymous committed 2ebcd0d

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

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.
 

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>"),

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)

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'])
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.