PHP development framework Yii Framework tutorial (16) UI component StarRating example

黄舟
Release: 2023-03-05 07:42:01
Original
1010 people have browsed it

CStarRating is mainly used for rating, showing a set of stars (5) for rating.

The basic usage is as follows

beginWidget('CActiveForm'); ?>widget('CStarRating',array('model'=>$model,'attribute'=>'rating','name'=>'rating','value'=>3,)); ?>
endWidget(); ?>
Copy after login

In the Controller, you can access the value of Star through $_POST['rating'], 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,
));}
Copy after login

CStarRating can also be set to read-only , at this time StarRating is used to display the rating and the user cannot modify the rating. This is achieved through 'readOnly' => true,.

PHP development framework Yii Framework tutorial (16) UI component StarRating example

The above is the content of the PHP development framework Yii Framework tutorial (16) UI component StarRating example. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!