CStarRating weird behaviour

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 ([font="Courier New"]$comment->rating[/font]) 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 !

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

));



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 ?