CStarRating is mainly used for scoring. a group of stars (five stars) are displayed for scoring. The basic usage is as follows: CStarRating is mainly used for scoring. a group of stars (five stars) are displayed for scoring.
The basic usage is as follows:
BeginWidget ('cactiveform');?> Widget ('cstarrating', array ('model' => $ model, 'attribute' => 'rating', 'name' => 'rating ', 'value' => 3,);?> EndWidget ();?>
In the Controller, you can use $ _ POST ['rating'] to access the value of Star. for example:
Public function actionIndex () {$ model = new DataModel (); $ model-> rating = 3; if (! Emptyempty ($ _ POST ['rating']) {$ model-> rating =$ _ POST ['rating']; if ($ model-> validate ()) {$ this-> render ('response', array ('model' => $ model,); return ;}$ this-> render ('index ', array ('model' => $ model ,));}
CStarRating can also be set to read-only. in this case, StarRating is used to display the score, and users cannot modify the score. This is achieved through 'readonly' => true.
The above is the sample content of the UI component StarRating in the PHP development Framework Yii Framework tutorial (16). For more information, see PHP Chinese website (www.php1.cn )!