Yii Framework Forum: [EXTENSION] spinner input field - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] spinner input field Rate Topic: -----

#21 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 04 January 2010 - 02:19 PM

View PostSpyros, on 04 January 2010 - 01:17 AM, said:

Hi,
I'll take a look at these problems and I'll upload a new version soon

Thanks

Thanks for instance response!

Waiting for update impatiently :-)

Useful ext :-)
0

#22 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 05 January 2010 - 01:10 AM

Hi,
Please check this attached update
This should work with the model value

Attached File(s)


0

#23 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 05 January 2010 - 04:09 AM

View PostSpyros, on 05 January 2010 - 01:10 AM, said:

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>

0

#24 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 05 January 2010 - 05:17 AM

My mistake
check this one please

Attached File(s)


0

#25 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 05 January 2010 - 05:46 AM

View PostSpyros, on 05 January 2010 - 05:17 AM, said:

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:
1. my attribute Time (MySQL type Time HH:mm:ss) - but doubt this should be a problem
0

#26 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 05 January 2010 - 05:50 AM

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
http://code.google.c...source/checkout
0

#27 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 05 January 2010 - 05:51 AM

View PostColt, on 05 January 2010 - 05:46 AM, said:

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:
1. my attribute Time (MySQL type Time HH:mm:ss) - but doubt this should be a problem


Found problem :-)
after commenting 'name' time spinner work just fine! :-)
// "name"=>"Time",
0

#28 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 05 January 2010 - 06:17 AM

yes, name is used for CFormModel and model & attribute for CActiveRecord
0

#29 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 05 January 2010 - 06:19 AM

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.

0

#30 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 05 January 2010 - 06:50 AM

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
0

#31 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 05 January 2010 - 07:46 AM

View PostSpyros, on 05 January 2010 - 06:50 AM, said:

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.
0

#32 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 16 January 2010 - 02:30 AM

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,
      ),

And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#33 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 16 January 2010 - 04:12 AM

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 . '"';
            } ;
        }

        ?>

And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#34 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 23 January 2010 - 09:25 AM

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.
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#35 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 24 January 2010 - 03:19 AM

How do you retrive the tabular data?
The right way is through
$_POST['model'][$i]['foobar']
You also have to use Yii 1.1
0

#36 User is offline   saegeek 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 245
  • Joined: 09-December 09
  • Location:Montpellier - France

Posted 24 January 2010 - 12:16 PM

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.
And [for] their saying, "Indeed, we have killed the Messiah, Jesus, the son of Mary, the messenger of God ." And they did not kill him, nor did they crucify him; but [another] was made to resemble him to them. And indeed, those who differ over it are in doubt about it. They have no knowledge of it except the following of assumption. And they did not kill him, for certain.Rather, God raised him to Himself.
0

#37 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 05 May 2010 - 06:22 PM

Now when testing with Yii 1.1.2 samples from:
http://www.yiiframew...on/spinner/#doc

I receive following error:
STextSpinner:
Parse error: parse error in C:\wamp\www\p2b8d\extensions\spinner\STextSpinner.php on line 128

CoLT
0

#38 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 05 May 2010 - 10:45 PM

View PostCoLT, on 05 May 2010 - 06:22 PM, said:

Now when testing with Yii 1.1.2 samples from:
http://www.yiiframew...on/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?
0

#39 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 06 May 2010 - 07:30 AM

View PostSpyros, on 05 May 2010 - 10:45 PM, said:

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
0

#40 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 06 May 2010 - 11:09 AM

I checked with Yii 1.1.2 and have no problem
Also STextSpinner.php does not have 128 lines:blink:
0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users