Hi,
I have a feeling that there is a bit of an issue regarding Float DBField types and the precision.
If I create a Float static, and setup a NumericField through which I enter values in the CMS, despite whatever depth of precision of value I enter, it always defaults to 3 decimal places.
As I set breakpoints through the code and step through, it appears that the correct value is being set initially (ie correct number of decimal places) but there is a problem (possibly with the underlying DB query) whereby only a 3 decimal place precision floating point value is read for display in the NumericField.
I can confirm this when I do an SQL query (or look at table via phpMyAdmin) on that field directly - it returns the value to 3 decimal places.
The reason I think this is a problem is that, even though the original setting of the value works, on successive reads and updates (even if the value in the NumericField in the CMS isn't altered) the value read value from the DB has less precision than the originally stored value and will be overwritten on the next "Save".
Any ideas on how to fix this or how to set the precision on Floats read into NumericFields? Would you agree that this is a bug?
public function extraStatics() {
return array('db' => array(
'Lat' => 'Float',
'Lng' => 'Float'
));
}
eg. CustomSiteConfig.php
public function updateCMSFields(FieldSet $fields) {
$fields->addFieldToTab("Root.Geo", new NumericField("Lat", "Latitude"));
$fields->addFieldToTab("Root.Geo", new NumericField("Lng", "Longitude"));
}
Thanks very much.
VWD