开发者

Format data being read in by CakePHP read() function

开发者 https://www.devze.com 2023-03-18 07:08 出处:网络
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).

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

精彩评论

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

关注公众号