H
H
hollanditkzn2017-05-31 11:15:56
Yii
hollanditkzn, 2017-05-31 11:15:56

Why does not change the given data?

I have implemented a notification system, only on the local computer everything works fine and the notification closes without problems, but when I uploaded it to the hosting, I ran into such a problem that when I closed the notification, it stopped closing, although the same code is used. And here it is not clear what is the reason.
There is a link in the template

echo Html::a($notif.'<br>', ['notification/notification', 'id' => $notification->id_zakaz]);

Which transfers the user to the controller and there the value should already change from not viewed to viewed. active 1 is an unviewed notification and it will always be recorded as unread by the user
public function actionNotification($id)
    {
        $model = $this->findModel(['id_zakaz' => $id]);
        $model->active = 0;
        $model->save();

        return $this->redirect(['zakaz/view', 'id' => $id]);
    }

But it turns out that when the code passes, then a redirect occurs and active remains 1, although, according to the logic, it should change to 0, and a redirect should be made.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-05-31
@hollanditkzn

most likely you have validation errors in the model. Display them with $model->getErrors() and fix them further

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question