now i have successfully installed the CStarRating widget on my page. it worked and i can retrieve the values that users input. But i find it’s impossible to set the initial value of the widget (e.g to demonstrate the average score previously put by all users).For example, if the average score of the current user is 8.5, it’s natural to have the 1st - 9th star selected on load, that’s what i call the default/initial value.
but how to set this value to CStarRating?
Is there something i can do about the htmlOptions or attributes property of the widget?
Or i have to find a way to get the <input id=‘score_9’…> checked?
ps. $(“input#score_9”).attr(“checked”,“checked”); will never make the 9th input checked. i don’t know why. but i don’t think this is the right solution.
hi Mdomba, thank you for that. i have changed the format of the ajax and they work fine now, but as you can see, the CStarRating control is not easy to control. i spent over 6 hours to figure how to set the initial value but failed.
For me the value is not set for one reason which I detected it, but I don’t know if you have better solution. The thing is that rating in my MySql is defined as Decimal(2,1), and in my model, Gii defined it as string. I believe since this value is string, the star value cannot set. I put a constant integer and/or float value, manually in CStar ‘value’ it worked well. I figure out to use
'value'=> (int) $model->rate
, and it worked, but using only attribute it doesn’t work. I even changed the model rate variable to integer it didn’t work. Any thought on this?