Actiondelete Redirect Error

hello,

I have problem. I have tasks and inside messages. When i delete some message , i can redirect to site " ‘task/update’, array(‘id’=>$model->id))); " .

My delete function:


public function actionDeleteMessage($id) {

        $this->loadModels($id)->delete();


// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser

        if (!isset($_GET['ajax']))

            $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('task/update', array('id'=>$id)));

    }

I have error:


Undefined variable: model

how I can appeal to $model->id task , when i have only $id in Message.

Your problem should be redirect to $_POST[‘returnUrl’],

because update action should have $model instance variable at first line of method.

So, in $_POST[‘returnUrl’] action with have to instantiate $model object firstly.

Do you want this ?


public function actionDeleteMessage($id) {

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

        $model->delete();

        if (!isset($_GET['ajax']))

            $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('task/update', array('id'=>$model->id)));

    }

[/quote]

Error:


Your request is invalid.

end path is : " task/update?0%5Bid%5D=58" ,

This task id = 13