Yii Framework Development Tutorial Zii Component-SliderInput Example_PHP Tutorial

WBOY
Release: 2016-07-14 10:07:56
Original
1351 people have browsed it

CJuiSliderInput displays a slider, which also encapsulates the JUI slider plug-in and can be used in a Form as a user input UI component.

The basic usage is as follows:
[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;'                                                                        
        ),  
)); ?>
50
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;'
),
)); ?>
50
endWidget(); ?>
After the user submits, use result.php to display the value entered by the user. The DataModel is defined here as follows:
[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,
 
));
}
Yii Framework Development Tutorial Zii Component-SliderInput Example_PHP Tutorial
  

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/477829.htmlTechArticleCJuiSliderInput 显示一滑动条,它也封装了 JUI slider插件,可以用在Form中作为用户输入UI组件。 基本用法如下: [php] div class=form ?php $form=$this-...
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!