YiiFramework development tutorial Zii component-SliderInput example _ PHP Tutorial

Source: Internet
Author: User
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 -...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.