- 1 第一个应用 Hello World
- 2 Yii Web 应用基础
- 3 为应用添加日志
- 4 Hangman 猜单词游戏实例
- 5 URL 管理
- 6 CComponent 组件
- 7 使用 CHtml 创建 Form
- 8 使用 FormModel
- 9 UI 组件 Widget 概述
- 10 UI 组件 自定义组件
- 11 UI 组件 ActiveForm 示例
- 12 UI 组件 ClipWidget 示例
- 13 UI 组件 ContentDecorator 示例
- 14 UI 组件 MaskedTextField 示例
- 15 UI 组件 MultiFileUpload 示例
- 16 UI 组件 StarRating 示例
- 17 UI 组件 TabView 示例
- 18 UI 组件 TextHighlighter 示例
- 19 UI 组件 TreeView 示例
- 20 UI 组件 Captcha 示例
- 21 UI 组件 自定义 Captcha 示例
- 22 UI 组件 Zii 组件简介
- 23 数据库-概述
- 24 数据库-DAO 示例
- 25 数据库-Query Builder 示例
- 26 数据库-Active Record 示例
- 27 数据库-关联 Active Record 示例
- 28 Data Provider 简介
- 29 Zii 组件-Menu 示例
- 30 Zii 组件-ListView 示例
- 31 Zii 组件-DetailView 示例
- 32 Zii 组件-GridView 示例
- 33 Zii 组件-Accordion 示例
- 34 Zii 组件-AutoComplete 示例
- 35 Zii 组件-Button 示例
- 36 Zii 组件-DatePicker 示例
- 37 Zii 组件-Dialog 示例
- 38 Zii 组件-ProgressBar 示例
- 39 Zii 组件-Slider 示例
- 40 Zii 组件-SliderInput 示例
- 41 Zii 组件-Tabs 示例
- 42 Zii 组件-Draggable 示例
- 43 Zii 组件-Droppable 示例
- 44 Zii 组件-Resizable 示例
- 45 Zii 组件-Selectable 示例
- 46 Zii 组件-Sortable 示例
- 47 主题 Theme 示例
- 48 多国语言示例
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
16 UI 组件 StarRating 示例
CStarRating 主要用于评分,显示一组星星(5 个)用于打分。
基本用法如下
<div class="form"> <?php $form=$this->beginWidget('CActiveForm'); ?> <?php $this->widget('CStarRating',array( 'model'=>$model, 'attribute'=>'rating', 'name'=>'rating', 'value'=>3, )); ?> <div class="row submit"> <?php echo CHtml::submitButton('Submit'); ?> </div> <?php $this->endWidget(); ?> </div><!-- form -->
在 Controller 中可以通过$_POST[‘rating’] 来访问 Star 的值,比如:
public function actionIndex() { $model=new DataModel(); $model->rating=3; if(!empty($_POST['rating'])) { $model->rating=$_POST['rating']; if($model->validate()) { $this->render('response', array( 'model' => $model, )); return; } } $this->render('index', array( 'model' => $model, )); }
CStarRating 也可以设为只读,此时 StarRating 用来显示评分而用户无法修改评分。这是通过’readOnly’=>true,来实现的。
图片 16.1 picture16.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论