please help me how to retrieve and save value to the database from cstar rating plugin or dzraty extension?
with examples.
please help me how to retrieve and save value to the database from cstar rating plugin or dzraty extension?
with examples.
First u can create the unique id
$this->widget('CStarRating', array(
'name' => 'ratingAjax[' . $value->ques_id . ']',
'id' => $value->ques_id,
'readOnly' => false,
'minRating' => .5,
'maxRating' => 5,
'ratingStepSize' => .5,
'callback' => '
function(){
$.ajax({
type: "POST",
url: "' . Yii::app()->createUrl('customer/support/starRatingAjax?question_id=' . $value->ques_id) . '",
data: "' . Yii::app()->request->csrfTokenName . '=' . Yii::app()->request->getCsrfToken() . '&question_id=' . $value->ques_id . '&rate=" + $(this).val(),
success: function(msg){
}})}'
));
then after your controller file put the action
public function actionstarRatingAjax() {
/*$ratingAjax=isset($_POST['rate']) ? $_POST['rate'] : 0;
echo "You are voting $ratingAjax through AJAX!";*/
$question_id=$_GET['question_id'];
$ratingAjax=isset($_POST['rate']) ? $_POST['rate'] : 0;
echo $ratingAjax.',question_id='. $question_id;
}
Best Regards,
Ankit Modi
everything ok but what is $value->ques_id? and why we are using this?
Hi
In my code i have wrtie the foreach loop so i have sepreate unique id if u are single CstarRating u can not remove this.
your coding does not work?
can u please provide code?
no im trying your code… its ok leave it… do you know how to use ajaxSubmit button?