Thanks for instance response!
Waiting for update impatiently
Useful ext
Thanks for instance response!
Waiting for update impatiently
Useful ext
Hi,
Please check this attached update
This should work with the model value
Thanks for update, trying to use.
The results:
First came:
Parse error: parse error in C:\wamp\www\ssis\protected\extensions\spinner\SNumericSpinner.php on line 218
[fixed] by adding <?php
Then strange thing happen, both date and number spinner stopped working:
My view code:
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'Time'); ?>
<?php
$this->widget('application.extensions.spinner.STimeSpinner',
array(
"name"=>"Time",
"model"=>$model,
"attribute"=>"Time",
"data"=>array(
"min"=>"06:00",
"max"=>"23:00",
"step"=>15,
"value"=>"12:00"
),
"width"=>60,
"delay"=>100,
"acceleration"=>"slow"
)
);
?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'Duration'); ?>
<?php
$this->widget('application.extensions.spinner.SNumericSpinner',
array(
"model"=>$model,
"attribute"=>"Duration",
"data"=>array(
"min"=>5,
"max"=>960,
"value"=>$model->Duration ? $model->Duration : 90,
"step"=>5
),
"width"=>40,
"text"=>"duration in minutes.",
"delay"=>130,
"acceleration"=>"slow"
)
);
?>
</div>
My mistake
check this one please
Now numeric spinner back online and works fine again
But time spinner still does not input values in form (error: no Time input), but now takes values from model when Updating added information(in format HH:mm:ss).
Maybe there is problem with:
The time spinner format should be in format HH:mm
When loading a new form does timeinput display anything or is it blank?
I also added htmlOptions attribute so you ca set readonly to false like this
<?php
$this->widget('application.extensions.spinner.SNumericSpinner',
array(
"model"=>$event,
"attribute"=>"event_ID",
"data"=>array(
"min"=>5,
"max"=>960,
"value"=>$event->event_ID ? $event->event_ID : 90,
"step"=>5
),
"width"=>40,
"text"=>"duration in minutes.",
"delay"=>130,
"acceleration"=>"slow",
"htmlOptions"=> array(
"readonly"=>false,
),
)
);
?>
The updated code is only in svn yet
Found problem
after commenting ‘name’ time spinner work just fine!
// "name"=>"Time",
yes, name is used for CFormModel and model & attribute for CActiveRecord
Now everything works very good:-) thanks for fixing it!
Some thoughts:
*When updating table entry time spinner takes Time type and shows not HH:mm, but HH:mm:ss(believe because in MySQL table field Time type is set).
*Under http://spyros.agilityhoster.com/demos/ even more simple examples could be put in Documentation because its very useful for Yii beginners for example:
activeCheckBoxList
ativeDropDownList
… and other simple and useful form elements examples.
Yes a check could be added so mysql time field should be treated correctly. You could also use a varchar(5) field to store the time in HH:MM format
For general Yii documentation stuff the best place is the Yii cookbook
Thanks for advice!
Basically yeah, this contribution would be very valuable in the cookbook.
I had to comment this line for disabling the readonly parameter @ SNumericSpinner.php:
//$this->htmlOptions["readonly"]= "true";
and remove the attribute :
"htmlOptions"=> array(
// "readonly"=>false,
),
I think it is useful also to add another parameter for defining other html options at the <div class="spinner"> block like :
'htmlOptions' => array(
'size' => 4, 'maxlength' => 4,'disabled'=>'true'
),
'divOptions' => array('style' => 'display: none;')
)
);
plus :
<div class='spinner' height="<?php
echo SNumericSpinner::getHeight();
?>px" <?php
if (!empty($this->divOptions))
{
foreach($this->divOptions as $name => $value)
{
echo $name . '="' . $value . '"';
} ;
}
?>
Snumeric spinner doesnt works when creating active fields (with $model) and tabular inputs like in :
foreach($items as $i=>$item)
{
$this->widget('application.extensions.spinner.SNumericSpinner',
array(
'model' => $item,
'attribute' => '[' . $i . ']foobar',);
}
It says : property model.[0]foobar is undefined
PS: fields like
'[' . $i . ']foobar'
works well with activeTextfield() and other active fields.
How do you retrive the tabular data?
The right way is through
$_POST[‘model’][$i][‘foobar’]
You also have to use Yii 1.1
You are right, I’m using Yii 1.1final and I retrieve data through
$_POST['model'][$i]['foobar']
But there is a problem with the spinner field. Using this code :
foreach($items as $i=>$item)
{
$this->widget('application.extensions.spinner.SNumericSpinner',
array(
'model' => $item,
'attribute' => '[' . $i . ']foobar',);
.....
It does not generate fields like
<input name="model[0][foobar]" ...>
while the same code works with ActiveTextFields
Try it yourself.
Now when testing with Yii 1.1.2 samples from:
http://www.yiiframework.com/extension/spinner/#doc
I receive following error:
STextSpinner:
Parse error: parse error in C:\wamp\www\p2b8d\extensions\spinner\STextSpinner.php on line 128
CoLT
Maybe there’s something (special or control character) in the spinner’s list. What is the array you used as a text list?
Just an example
<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>
CoLT
I checked with Yii 1.1.2 and have no problem
Also STextSpinner.php does not have 128 lines:blink: