alper
(Adoruatli)
1
<?php echo $form->textField($model,‘vade_orani’);?>
This input shows like "1.000"-"2.000"-"3.000" values .
I want to only show like "1","2","3". It doesnt matter after dot values.
I looked formatter class but i dont get it how can i use them on this.
How can i do this ?
iivano71
(Igor Zg1987)
2
ek CFormatter numberFormat format numbers from "1","2" to 1.000 , 2.0000, i sugest you to imput nubers in database as a interger , or you just use
if(strpos('.',$string)){
$str = explode('.',$string);
echo $str[0];
}
Another way of doing it without touching your database is by using CHtml::textField, with it you can control the value
$val = isset($model->vade_orani)? $model->vade_orani : 0;
echo CHtml::textField(‘Modelname[vade_orani]’,intval($val));
Or
You create a property in your model:
public getIntVadeOrani(){
return intval($model->vade_orani);
}
And on your view:
<?php echo $form->textField($model,‘intVadeOrani’);?>
Hope it helps
jacmoe
(Jacob Moena)
4
Yet another way is by using number_format:
echo number_format($number);
Plain and simple.
If you want decimals, pass the number of decimals:
echo number_format($number, 2);
Read more:
http://www.php.net/manual/en/function.number-format.php
alper
(Adoruatli)
5
Thank you for all helps.
Another way i used "atferFind" fucntion in model file.
public function afterFind()
{ $this->vade_orani= Yii::app()->numberFormatter->format('#',$this->vade_orani); }