Decimal values lost
After inserting a decimal value (ie 3.14145) into a text field (any text field, in add or edit mode) the decimal gets lopped off and the displayed value is before the decimal point.
Anyone fixed this? Is this in the save() function in concrete/controller.php ?
if you have a block or another concrete5 added db table and thus field it is recommended by me to use either a N or F designation in your db.xml, otherwise mysql won't convert it to an integer which is a whole number.
I settled on type of N for my app dealing with numbers and money, not sure why at the time but that is what i did :) Float might be more applicable for storing pi
I have had it set to N since it's creation:
<field name="price" type="N">
It is somewhere when I submit the form, I think it's code cleaner too (but I can't find code cleaner yet) here is the form field:
<?= $form->text('price', $price, array('style' => 'width: 280px')); ?>
*** UPDATE ***
I have temporarily solved it by making the DB field type X and it stores it as a string.
When using type="N" it creates a field type of "decimal(10,0)" which rounds off the decimal. Attempting to use something like type="N10.2" generates an mysql error: 1064 during the block install. I simply can't believe we have to settle on storing them as string values.
<table name="bt_Timecard"> <field name="tcID" type="I"> <key /> <autoincrement /> <unsigned /> </field> <field name="taskID" type="I" /> <field name="Date" type="T" /> <field name="Hours" type="decimal(6, 2)" /> </table>
In the db.xml use this format:
<field name="Price" type="N" size="10.2"></field>
You can find even more gold nuggets in: \concrete\src\Database\Schema\Parser\Axmls.php