时间:2021-07-01 10:21:17 帮助过:5人阅读
基本用法如 下:
beginWidget('CActiveForm'); ?> errorSummary($model); ?> widget('zii.widgets.jui.CJuiSliderInput', array( 'model'=>$model, 'attribute'=>'size', 'name'=>'my_slider', 'value'=>50, 'event'=>'change', 'options'=>array( 'min'=>0,'max'=>100, 'slide'=>'js:function(event,ui){ $("#amount").text(ui.value);}', ),'htmlOptions'=>array( 'style'=>'width:200px; float:left;'), )); ?> 50 endWidget(); ?>
用户提交后,使用result.php来显示用户输入的值,这里定义DataModel如下:
class DataModel extends CFormModel{public $size; public function rules(){return array(array('size', 'safe'),);}}
修改SiteController的indexAction方法:
public function actionIndex(){ $model=new DataModel(); $model->size=50; if(!emptyempty($_POST['DataModel'])){ $model->attributes=$_POST['DataModel']; if($model->validate()){ $this->render('result', array('model' => $model,)); return;} } $this->render('index', array('model' => $model, ));}
以上就是PHP开发框架Yii Framework教程(40) Zii组件-SliderInput示例的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!