[Solved]Problem In Using X-Editable Extension

hello guys, I am using x-editable extension in my project and want to update in cgridview my record using this extension, but when I click on some editable field then a popup appears and I change the data but when click on "ok" button to update it, then it gives error that "The request is invalid".

I am sharing my cgridview and controller action code here. please if anyone knows the answer then tell me.

[PostController.php code]




public function actionUpdate()

	{

		$model=$this->loadModel();

		if(isset($_POST['Post']))

		{

			$model->attributes=$_POST['Post'];

			if($model->save())

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

		}


		$this->render('update',array(

			'model'=>$model,

		));

	}



[and post admin cgridview code of the editable field is]


array(

           'class' => 'editable.EditableColumn',

           'name' => 'user_name',

           'headerHtmlOptions' => array('style' => 'width: 110px'),

           'editable' => array(  

                  'url'        => $this->createUrl('post/update'),

                  'placement'  => 'right',

              )               

        ),

You’re not passing an id variable to your action update so you’re not telling it what record to update.

Follow the examples on the inline editing extension page. I’ve used them and they all work.

Also, in your model make sure you have a rule defined for every item you want to use inline editing on or it won’t save via inline editing.

Issue is solved using.


public function actionUpdate()

	{

		$es = new EditableSaver('Post');

                $es->onBeforeUpdate = function($event) {

                    $event->sender->setAttribute('modified_date', date('Y-m-d H:i:s'));

                };

                $es->update();

	}