We have z3c.form Float fields with float values. The values rendered in the form appeat to be rounded after the 3rd digit after the comma - which is a pita because the value represent geo locations. The culprit is zope.i18n.format.NumberFormat where some scary number formatting happens place. Is there a way to register a different formatter for Float fields or specify a different precision for the formatting of float values?
I believe, you can override data converter from field value to display widget value. (As I remember, it was the default data converter, which calls the number format formatter).
from z3c.form.interfaces import IDataConverter
from z3c.form.interfaces import DISPLAY_MODE
from z3c.form.interfaces import IWidget
from z3c.form.converter import FloatDataConverter as FloatDataConverterBase
from zope.schema.interfaces import IFloat
class FloatDataConverter(FloatDataConverterBase):
implements(IDataConverter)
adapts(IFloat, IWidget)
def toWidgetValue(self, value):
if self.widget.mode != DISPLAY_MODE:
return super(FloatDataConverter, self).toWidgetValue(value)
else:
# magic
Thanks for help. Going with a standard TextLine field forward...this is much easier as workaround than to fiddle with these insane z3c.form indirections.