Update Record In A View To

Ho una view di un dettaglio: http://www.miosito/a...e/view/139.html

al suo interno ho un pulsante o un link “mipiace”, al suo click il campo del database chiamato likeme…dovrebbe essere aggiornato con il suo attuale valore + 1.Ho creato nel controller offerte l’azione:




public function actionLike($id)

        {

                $model=$this->loadModel($id);


                $post=Offerte::model()->findByPk($id);

                $post->likeme= $post->likeme + 1;

                $post->save(); // save the change to database


                                $this->redirect(array('view','id'=>$model->id));

                


        }



I added in the access rules like

then in the view:




<?php


echo CHtml::ajaxSubmitButton(


    'Mi piace',


    array('offerte/like'),


);

?>



but does not work … does not perform the action according to me, however with the delete




<?php echo CHtml::link('Elimina','#',array('submit'=>array('offerte/delete','id'=>$value->id),'confirm'=>'Vuoi eliminare questa Offerta?'));?>



I’m missing a parameter?

Hi,

Please check with your controller’s filter for postonly added for delete action.

if so… your ajax request must be POST request.

Cheers!

I have to do the update at click




public function actionLike($id)

        {

                $model=$this->loadModel($id);


                $post=Offerte::model()->findByPk($id);

                $post->likeme= $post->likeme + 1;

                $post->save(); // save the change to database


                                $this->redirect(array('view','id'=>$model->id));