This is my first extension so I made something simple. A spinner form element similar to Java JSpinner
Resources ¶
Documentation ¶
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. | ||||||||||||||||||
width | integer | The width of the spinner's input field in pixels (default 30). | ||||||||||||||||||
height | integer | The height of the spinner (default 22). | ||||||||||||||||||
bgColor | string | The background color of the spinner's buttons (default white). | ||||||||||||||||||
text | string | A text printed next to the spinner. | ||||||||||||||||||
delay | integer | 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 | ||||||||||||||||||
htmlOptions | array | 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:
|
<div>
<p>
<b>SNumericSpinner:</b>
<?php $this->widget('application.extensions.spinner.SNumericSpinner',
array(
"name"=>"stockInt",
"data"=>array(
"min"=>0,
"max"=>100,
"value"=>10
),
"width"=>40,
"text"=>"A numeric (integer) spinner",
"delay"=>150,
"acceleration"=>"slow"
)
); ?><br />
<?php $this->widget('application.extensions.spinner.SNumericSpinner',
array(
"name"=>"stockFloat",
"data"=>array(
"min"=>0,
"max"=>100,
"step"=>0.5,
"value"=>5.50
),
"width"=>60,
"precision"=>2,
"text"=>"A numeric (float) spinner",
"delay"=>100,
"acceleration"=>"fast"
)
); ?>
</p>
<p>
<b>STextSpinner:</b>
<?php $this->widget('application.extensions.spinner.STextSpinner',
array(
"name"=>"category",
"data"=>array(
"list"=> array("Category A","Category B","Category C"),
"value"=> 0,
),
"width"=>100,
"text"=>"A string spinner",
)
); ?>
</p>
<p>
<b>A Time Spinner:</b>
<?php $this->widget('application.extensions.spinner.STimeSpinner',
array(
"name"=>"time",
"data"=>array(
"min"=>"00:00",
"max"=>"23:59",
"step"=>15,
"value"=>"12:00"
),
"width"=>60,
"text"=>"A Time spinner (15 minutes step)",
"delay"=>100,
"acceleration"=>"slow"
)
); ?>
</p>
</div>
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.
Demo page is error
The demo page is error unfortunately...
Update the demo
Please, fix the demo !
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.