Commit 575e6946 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Patch IntegerWidget.render_view to convert a float to an int automatically.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11696 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 268679b6
...@@ -260,6 +260,7 @@ def CheckBoxWidget_render(self, field, key, value, REQUEST): ...@@ -260,6 +260,7 @@ def CheckBoxWidget_render(self, field, key, value, REQUEST):
name="default_%s:int" % (key, ), name="default_%s:int" % (key, ),
value="0") value="0")
] ]
if value: if value:
rendered.append(render_element("input", rendered.append(render_element("input",
type="checkbox", type="checkbox",
...@@ -342,7 +343,7 @@ TextWidget.render_view = TextWidget_patched_render_view ...@@ -342,7 +343,7 @@ TextWidget.render_view = TextWidget_patched_render_view
class IntegerWidget(TextWidget) : class IntegerWidget(TextWidget) :
def render(self, field, key, value, REQUEST) : def render(self, field, key, value, REQUEST) :
"""Render link. """Render an editable integer.
""" """
if type(value) is type(1.0): if type(value) is type(1.0):
value = int(value) value = int(value)
...@@ -365,6 +366,12 @@ class IntegerWidget(TextWidget) : ...@@ -365,6 +366,12 @@ class IntegerWidget(TextWidget) :
size=field.get_value('display_width'), size=field.get_value('display_width'),
extra=field.get_value('extra')) extra=field.get_value('extra'))
def render_view(self, field, value):
"""Render a non-editable interger."""
if isinstance(value, float):
value = int(value)
return TextWidget.render_view(self, field, value)
from Products.Formulator.StandardFields import IntegerField from Products.Formulator.StandardFields import IntegerField
from Products.Formulator.Validator import IntegerValidator from Products.Formulator.Validator import IntegerValidator
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment