YiiFramework development tutorial Zii component-SliderInput example. CJuiSliderInput displays a slide. it also encapsulates the JUIslider plug-in and can be used in Form as the UI component for user input. Basic usage: [php] divclassform? Php $ form $ this-CJuiSliderInput displays a slide. it also encapsulates the JUI slider plug-in and can be used in Form as the UI component for user input.
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 );}',
),
'Htmlopexception' => 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 );}',
),
'Htmlopexception' => array (
'Style' => 'width: 200px; float: left ;'
),
);?>
50
EndWidget ();?>
After the user submits the request, use result. php to display the value entered by the user. DataModel is defined 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 '),
);
}
}
Modify the indexAction method of SiteController:
[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,
));
}
-
The http://www.bkjia.com/PHPjc/477829.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/477829.htmlTechArticleCJuiSliderInput displays a slide, which also encapsulates the JUI slider plug-in that can be used in Form as a user input UI component. Basic usage: [php] p class = form? Php $ form = $ this -...