From ba841b120d946be11f4497f6e4349ae4971e481d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Fri, 8 Jun 2007 15:30:07 +0000
Subject: [PATCH] add render dict to search float field based on user format

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14751 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/FormulatorPatch.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/product/ERP5Form/FormulatorPatch.py b/product/ERP5Form/FormulatorPatch.py
index 3a68f57634..13ec73ad58 100644
--- a/product/ERP5Form/FormulatorPatch.py
+++ b/product/ERP5Form/FormulatorPatch.py
@@ -1125,6 +1125,32 @@ class FloatWidget(TextWidget):
         """Render the field as PDF."""
         return self.format_value(field, value)
 
+
+    def render_dict(self, field, value):
+      """
+        This is yet another field rendering. It is designed to allow code to
+        understand field's value data by providing its type and format when
+        applicable.
+
+        It returns a dict with 3 keys:
+          type  : Text representation of value's type.
+          format: Type-dependant-formated formating information.
+                  This only describes the field format settings, not the actual
+                  format of provided value.
+          query : Passthrough of given value.
+      """
+      input_style = field.get_value('input_style')
+      precision = field.get_value('precision')      
+      if precision != 0:
+        for x in xrange(1, precision):
+          input_style += '5'
+      else:
+        input_style = input_style.split('.')[0]
+      return {'query': value,
+              'format': input_style,
+              'type': 'date'}
+
+
 FloatWidgetInstance = FloatWidget()
 from Products.Formulator.StandardFields import FloatField
 FloatField.widget = FloatWidgetInstance
-- 
2.30.9