Commit 2e6ec56a authored by Kevin Deldycke's avatar Kevin Deldycke

Render Float display field.

Patch on float field render to add:
  * replacement of spaces by unbreakable spaces if the content is float-like,
  * support of extra CSS class when render as pure text.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4115 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4da5e8ee
...@@ -810,11 +810,30 @@ class FloatWidget(TextWidget): ...@@ -810,11 +810,30 @@ class FloatWidget(TextWidget):
def render_view(self, field, value): def render_view(self, field, value):
"""Render Float display field """
Render Float display field.
This patch add:
* replacement of spaces by unbreakable spaces if the content is float-like
* support of extra CSS class when render as pure text
""" """
value = self.format_value(field, value) value = self.format_value(field, value)
float_value = None
try:
float_value = float(value.replace(' ', ''))
except:
pass
if float_value != None:
value = value.replace(' ', ' ')
extra = field.get_value('extra')
if extra not in (None, ''):
value = "<div %s>%s</div>" % (extra, value)
return TextWidgetInstance.render_view(field, value) return TextWidgetInstance.render_view(field, value)
FloatWidgetInstance = FloatWidget() FloatWidgetInstance = FloatWidget()
from Products.Formulator.StandardFields import FloatField from Products.Formulator.StandardFields import FloatField
FloatField.widget = FloatWidgetInstance FloatField.widget = FloatWidgetInstance
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