yii rules numerical float
04Dec11
if you want to validate a float number you can use this:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(array(‘price’, ‘numerical’, ‘integerOnly’=>FALSE,’numberPattern’=>’/^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$/’,'message’=>’erroreeeeee’),
);
}
Example: 19.32
Filed under: Yii | 1 Comment
Etichete:yii

You might want to consider extending CNumberValidator to do this. That way it is reusable. We extended the CNumberValidator to make our own validator for Zurmo (http://www.zurmo.org), an open source crm application.