CStarRating Buggy




'minRating' => 1,

		'maxRating' => 5,

		'value' => 0,

		'ratingStepSize' => 0.5,

		'starCount' => 4,



produce 4.5 stars




'minRating' => 1,

		'maxRating' => 5,

		'value' => 0,

		'ratingStepSize' => 0.5,

		'starCount' => 5,



produce 9 stars




'minRating' => 1,

		'maxRating' => 5,

		'value' => 0,

		'ratingStepSize' => 0.5,

		'starCount' => 2,



2.25

:o


class CStarRating extends CInputWidget

{

	/**

	 * @var integer the number of stars. Defaults to 5.

	 */

	public $starCount=5;



:D

this is the source of the problem




protected function renderStars($id,$name)

	{

		$inputCount=(int)(($this->maxRating-$this->minRating)/$this->ratingStepSize+1);

		$starSplit=(int)($inputCount/$this->starCount);

		if($this->hasModel())

		{

			$attr=$this->attribute;

			CHtml::resolveName($this->model,$attr);

			$selection=$this->model->$attr;

		}

		else

			$selection=$this->value;

		$options=$starSplit>1 ? array('class'=>"{split:{$starSplit}}") : array();

		for($value=$this->minRating, $i=0;$i<$inputCount; ++$i, $value+=$this->ratingStepSize)

		{

			$options['id']=$id.'_'.$i;

			$options['value']=$value;

			if(isset($this->titles[$value]))

				$options['title']=$this->titles[$value];

			else

				unset($options['title']);

			echo CHtml::radioButton($name,!strcmp($value,$selection),$options) . "\n";

		}

	}



I think the (int) casting does something bad to the rating… trying to figure it what exactly…

It seems like it ment to work only with integers…

But half rating is normal actually… :o

To make it show 5 stars with step 0.5 you should set




'minRating' => 0.5,

		'maxRating' => 5,

		'ratingStepSize' => 0.5,

		'starCount' => 5,



But in spite of that, starCount just not work as it should

Another issue I noticed


'minRating' => 0.5,

		'maxRating' => 5,

		'value' => 0.75,

		'ratingStepSize' => 0.5,

		'starCount' => 5,

will show nothing…

So to make it show something you should round to closest half… or ceil floor…

this issue also annoying bug

http://www.yiiframework.com/forum/index.php?/topic/24793-cstarrating-remove-vote/

It interesting that it seems like no one give attention to the cancel button…

Need heavy hacking via try catch to manage do with it something…