Yii CStarRating不显示半满值的半满星

时间:2015-02-24 11:30:17

标签: yii rating

这是我在yii中用Cgridview编写的代码。

 array(
         'header'=>'Avg Rating',
         'type' => 'raw',
         'value'=>'$this->grid->controller->widget(\'CStarRating\',
                                            array(
                                                    \'name\'=>$data->rating.$data->id,
                                                    \'id\'=>$data->id,
                                                    \'readOnly\' => true,
                                                    \'value\' =>2.5,
                                                     \'minRating\'=>1,
                                                     \'maxRating\'=>5,
                                                     \'htmlOptions\'=>array(\'style\'=>\'text-align:center;\',)),true)." <br/>1,011 Reviews"',
         'htmlOptions'=>array('style'=>'text-align:center;'),
    ),

当我传递整数时,它会显示正确的填充星形,但是当我传递2.5之类的值时,它会显示所有星形空白。

1 个答案:

答案 0 :(得分:0)

你必须这样做:

array(
     'header'=>'Avg Rating',
     'type' => 'raw',
     'value'=>'$this->grid->controller->widget(\'CStarRating\',
                                        array(
                                                \'name\'=>$data->rating.$data->id,
                                                \'id\'=>$data->id,
                                                \'readOnly\' => true,
                                                \'value\' =>2.5,
                                                 \'minRating\'=>0.5,
                                                 \'maxRating\'=>5,
                                                 \'ratingStepSize\' => 0.5,
                                                 \'htmlOptions\'=>array(\'style\'=>\'text-align:center;\',)),true)." <br/>1,011 Reviews"',
     'htmlOptions'=>array('style'=>'text-align:center;'),
),

或可以尝试minRatingratingStepSize的其他值。