Yii 1.1: spinner

A spinner input form field

This is my first extension so I made something simple. A spinner form element similar to Java JSpinner



All spinners are based on the SBaseSpinner class.
Spinners can be Numeric Spinners (SNumericSpinner), Text Spinners (STextSpinner) and Time Spinners (STimeSpinner).
Numeric Spinners are divided in integer and float spinners.This depends on the min, max or step data values of the spinner.If one of those is a float the spinner is treated as a float spinner alse as an integer one.
Spinners attributes are:
type string A read only attribute. It's automatically decided depending on the kind of the spinner. The types can be numeric, string or time.
model CActiveRecord A active record model of the attribute associated with the spinner .
attribute string The attribute of the active record model.
name string The name of the form model attribute.
widthinteger The width of the spinner's input field in pixels (default 30).
heightinteger The height of the spinner (default 22).
bgColorstring The background color of the spinner's buttons (default white).
text string A text printed next to the spinner.
delayinteger The delay of the spinner's values update in ms when the mouse is kept pressed on up/down button (Default is 100).Small delays means faster spinner speed
acceleration string Spinner's speed acceleration when the mouse is kept pressed on up/down button.Valid values are none, slow, normal, fast. Default is none
htmlOptionsarray The textbox htmlOptions.You can set the textbox as editable by setting "readonly"=>false
data array An array with the spinners data.Data elements depend on the spinner's type. These elements can be:
All Spinners:
valuemixed The initial value of the spinner.If not provided the first element of a text spinner or the minimum value of numeric/time spinners is used.Also these values are used if the provided value is invalid (out of range in numeric spinners etc).
Text Spinners:
listarray An array with the list of the string type spinner.
Numeric/Time Spinners:
minmixed The minimum value of the spinner.For numeric spinners must be an integer or float (default 0) and for time spinners a string in the form of HH:MM (default 00:00)
maxmixed The maximum value of the spinner.For numeric spinners must be an integer or float (default 0) and for time spinners a string in the form of HH:MM (default 23:59)
stepmixed The step value of the spinner increase and decrease.For numeric spinners must be an integer or float (default 1) and for time spinners an integer in minutes (default 30)
Numeric (Float) Spinners:
precisioninteger The number of decimal digits displayed in the spinner.
    <?php $this->widget('application.extensions.spinner.SNumericSpinner',
        "text"=>"A numeric (integer) spinner",
    ); ?><br />
      <?php $this->widget('application.extensions.spinner.SNumericSpinner',
        "text"=>"A numeric (float) spinner",
    ); ?>
    <?php $this->widget('application.extensions.spinner.STextSpinner',
        "list"=> array("Category A","Category B","Category C"),
        "value"=> 0,
        "text"=>"A string spinner",
    ); ?>
    <b>A Time Spinner:</b>
    <?php $this->widget('application.extensions.spinner.STimeSpinner',
        "text"=>"A Time spinner (15 minutes step)",
    ); ?>

Change Log

January 8, 2010

  • Version 1.3.1 Fixed some bugs related with moddels
    Added htmlOptions attribute

July 16, 2009

  • Version 1.3 Spinners are divided in 3 categories now SNumericSpinner for the int and float spinners, STextSpinner for the string spinners and STimeSpinner for the new time spinners.
    If you are upgrading the only thing you have to change is the : $this->widget('application.extensions.spinner.SSpinner' to $this->widget('application.extensions.spinner.SNumericSpinner' if it's a numeric spinenr etc.

May 22, 2009

  • Version 1.2
    You can set the delay of the spinner's value update so you can control the speed of the spinner when the mouse is kept pressed on a button (Spinner's delay parameter)
    Also when button is kept pressed this speed increases (Spinner's acceleration parameter. Values can be "none", "slow" , "normal" and "fast")

May 21, 2009

  • Version 1.1
    When the mouse is pressed on the spinner the numbers increase/decrease faster
    Fixed a bug with I.E. and string type spinners

May 21, 2009

  • Initial release.

Total 2 comments

#14333 report it
realtebo at 2013/08/05 05:10am
Update the demo

Please, fix the demo !

#1952 report it
junxiong at 2010/10/19 04:37am
Demo page is error

The demo page is error unfortunately...

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: Spyros
  • Category: User Interface
  • Votes: +1 / -1
  • Downloaded: 1,136 times
  • Created on: May 21, 2009
  • Last updated: Jan 8, 2010