开发者

Format data being read in by CakePHP read() function

I am using CakePHP to display an input field that has a "price" variable in it upon editing. Coming from the database this number has a 5 decimal points (for complex calculations).

Without setting the column in the database to be set to only float to 2 points, how would I go about converting this variable to float to only 2 points?

<?php echo $form->input('price'); ?>

Please let me know if you need any further information from 开发者_如何学Cme.


Did you specify a model when you did your $form->create('Model');

You should be able to manipulate the $this->data by specifying the Model and field.

<?php echo $form->text('price', 
          array('value' => round($this->data['Model']['price'], 2)));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜