Skip to content

Commit

Permalink
Using sprintf to convert number into non-scientific notation
Browse files Browse the repository at this point in the history
  • Loading branch information
wnasich committed Jan 30, 2014
1 parent 43604f6 commit a7f50e0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -1173,11 +1173,8 @@ protected function _magicOptions($options) {
!isset($options['step'])
) {
if ($type === 'decimal') {
if (preg_match('/[0-9]+,([0-9]+)/', $fieldDef['length'], $fieldLenght) && intval($fieldLenght[1]) > 0) {
$options['step'] = '0.' . str_repeat('0', $fieldLenght[1] - 1) . '1';
} else {
$options['step'] = 1;
}
$decimalPlaces = substr($fieldDef['length'], strpos($fieldDef['length'], ',') + 1);
$options['step'] = sprintf('%.' . $decimalPlaces . 'F', pow(10, -1 * $decimalPlaces));
} elseif ($type === 'float') {
$options['step'] = 'any';
}
Expand Down

0 comments on commit a7f50e0

Please sign in to comment.