public function actionUpdate($id)
    {
        if (!\Yii::$app->user->can('update'))
            return $this->alert(Module::t('core', 'Access denied.'));

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

        // $parent_node is empty, so it must be set
        if($one = $model->parents(1)->one())
        {
            $model->parent_node = $one->id;
            // new code
            $loaded = $model->load(\Yii::$app->request->post());
            
            // The General case
            if ($loaded && $model->save()) {
                return YII_DEBUG 
                    ? $this->redirect(['index'])
                    : $this->redirect(\Yii::$app->request->referrer);
            } else {
                return $this->renderAjax('update', [
                    'model' => $model,
                ]);
            }
        } else {
            \Yii::$app->session->setFlash(
                'warning',
                \Yii::t('core', 'Node has not parent.')
            );
            return $this->redirect(['index']);
        }
    }
public function actionUpdate($id)
    {
        if (!\Yii::$app->user->can('update'))
            return $this->alert(Module::t('core', 'Access denied.'));

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

        // $parent_node is empty, so it must be set
        if($one = $model->parents(1)->one())
        {
            $model->parent_node = $one->id;
            // new code
            $loaded = $model->load(\Yii::$app->request->post());
            
            // The General case
            if ($loaded && $model->save()) {
                return YII_DEBUG 
                    ? $this->redirect(['index'])
                    : $this->redirect(\Yii::$app->request->referrer);
            } else {
                return $this->renderAjax('update', [
                    'model' => $model,
                ]);
            }
        } else {
            \Yii::$app->session->setFlash(
                'warning',
                \Yii::t('core', 'Node has not parent.')
            );
            return $this->redirect(['index']);
        }
    }
public function actionUpdate ( $ id ) { if ( ! \ Yii :: $ app -> user -> can ( 'update' ) ) return $ this -> alert ( Module :: t ( 'core' , 'Access denied.' ) ) ; $ model = $ this -> findModel ( $ id ) ; // $parent_node is empty, so it must be set if ( $ one = $ model -> parents ( 1 ) -> one ( ) ) { $ model -> parent_node = $ one -> id ; // new code $ loaded = $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) ; // The General case if ( $ loaded && $ model -> save ( ) ) { return YII_DEBUG ? $ this -> redirect ( [ 'index' ] ) : $ this -> redirect ( \ Yii :: $ app -> request -> referrer ) ; } else { return $ this -> renderAjax ( 'update' , [ 'model' => $ model , ] ) ; } } else { \ Yii :: $ app -> session -> setFlash ( 'warning' , \ Yii :: t ( 'core' , 'Node has not parent.' ) ) ; return $ this -> redirect ( [ 'index' ] ) ; } }
Updates an existing Rubric model.
If update is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed
Updates an existing Rubric model . If update is successful the browser will be redirected to the index page .