Yii Framework 开发教程Zii组件-SliderInput示例
基本用法如下:
[php]
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;'
),
)); ?>
endWidget(); ?>
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;'
),
)); ?>
endWidget(); ?>
用户提交后,使用result.php来显示用户输入的值,这里定义DataModel如下:
[php]
class DataModel extends CFormModel
{
public $size;
public function rules()
{
return array(
array('size', 'safe'),
);
}
}
class DataModel extends CFormModel
{
public $size;
public function rules()
{
return array(
array('size', 'safe'),
);
}
}
修改SiteController的indexAction方法:
[php]
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,
));
}
public function actionIndex()
{
$model=new DataModel();
$model->size=50;
if(!empty($_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教程(17) UI 组件 TabView示例
-
PHP开发框架Yii Framework教程(18) UI 组件 TextHighlighter示例
-
PHP开发框架Yii Framework教程(16) UI 组件 StarRating示例
-
PHP开发框架Yii Framework教程(19) UI 组件 TreeView示例
-
PHP开发框架Yii Framework教程(15) UI 组件 MultiFileUpload示例
-
PHP开发框架Yii Framework教程(37) Zii组件-Dialog示例
-
Yii Framework 开发教程Zii组件-Menu 示例_PHP教程
-
PHP开发框架Yii Framework教程(20) UI组件 Captcha示例
-
PHP开发框架Yii Framework教程(14) UI 组件 MaskedTextField示例
-
PHP开发框架Yii Framework教程(38) Zii组件-ProgressBar示例