Yii Framework Forum: CStarRating weird behaviour - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CStarRating weird behaviour readOnly parameter ? Rate Topic: -----

#1 User is offline   smoothcoder 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 03-December 09
  • Location:Thailand

Posted 08 March 2010 - 01:08 PM

I've decided to add some rating to "comments" of my blog model applied to lyrics. (I can test versions in 1.0.11 or 1.1.0 and same bad behaviour).

Before using CStarRating, I just had to add a new column rating to my table of comments. Then, to make the display, inside the loop of post comments ($comment->rating) I use:
if ($comment->rating>0)
$this->widget('CStarRating',
	array('name'=>'rating',
	'readOnly' =>true,
	'value' => $comment->rating,
	'starWidth' => 8,
	'titles'=>array(1=>'weak',2=>'so so',3=>'good',4=>'thats great',5=>'the best'),
	'maxRating'=>5,
	'allowEmpty'=>true)
);


And in the form, waiting for a new comment , I use :
$this->widget('CStarRating',
	array('name'=>'rating',
	'readOnly' =>false,
	'starWidth' => 8,
	'titles'=>array(1=>'weak',2=>'so so',3=>'good',4=>'thats great',5=>'the best'),
	'maxRating'=>5,
	'allowEmpty'=>true));


Nothing extraordinary ! Look at parameter "readOnly" . In the list loop, I want it "true" for the rating has been posted and it should not be changed any more by anyone. Problem is it doesnt behave correctly :-[ . What did I miss ? :blink:

Do I have to do some pre-settings or registration script before using CStarRating ?

Anyone has an online example - working one - of CstarRating ? Mine, which is faulty now is on http://www.discardedteenz.com/post/salt-water-lyrics. But I am waiting for your helps to solve that !
0

#2 User is offline   Theill11 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 03-March 10
  • Location:@ localhost

Posted 08 March 2010 - 09:27 PM

Try this:

$this->widget('CStarRating',array(
  'model'=>$comment,
  'attribute'=>'rating',
  'maxRating'=>5,
  'titles'=>array(1=>'weak',2=>'so so',3=>'good',4=>'thats great',5=>'the best'),
  'allowEmpty'=>true
));

0

#3 User is offline   smoothcoder 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 03-December 09
  • Location:Thailand

Posted 09 March 2010 - 07:24 AM

Thanks Komodo. It worked. :P
So your instruction is more for the "display" while the one I was using more for "creation".That's how I understood it.

Speaking about something else, I noticed how slow the display is. I can see the radio buttons appearing one by one before seeing the stars (ugly by the way).
So I'm going to work around this. A bit of css I suppose ?
0

Share this topic:


Page 1 of 1
  • 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