src/actions/UpdateAction.php
public function run($id = null)
    {
        if ($id === null) {
            $model = new Measure;
            $model->loadDefaultValues();
        } else {
            $model = $this->controller->findModel($id);
        }
        $isLoaded = $model->load(\Yii::$app->request->post());
        $hasAccess = ($model->isNewRecord && \Yii::$app->user->can('measure-create-measure'))
            || (!$model->isNewRecord && \Yii::$app->user->can('measure-edit-measure'));
        if ($isLoaded && !$hasAccess) {
            throw new ForbiddenHttpException;
        }
        if ($isLoaded && $model->save()) {
            return $this->controller->redirect(['update', 'id' => $model->id]);
        } else {
            return $this->controller->render(
                'update',
                [
                    'hasAccess' => $hasAccess,
                    'model' => $model,
                ]
            );
        }
    }
public function run($id = null)
    {
        if ($id === null) {
            $model = new Measure;
            $model->loadDefaultValues();
        } else {
            $model = $this->controller->findModel($id);
        }
        $isLoaded = $model->load(\Yii::$app->request->post());
        $hasAccess = ($model->isNewRecord && \Yii::$app->user->can('measure-create-measure'))
            || (!$model->isNewRecord && \Yii::$app->user->can('measure-edit-measure'));
        if ($isLoaded && !$hasAccess) {
            throw new ForbiddenHttpException;
        }
        if ($isLoaded && $model->save()) {
            return $this->controller->redirect(['update', 'id' => $model->id]);
        } else {
            return $this->controller->render(
                'update',
                [
                    'hasAccess' => $hasAccess,
                    'model' => $model,
                ]
            );
        }
    }
public function run ( $ id = null ) { if ( $ id === null ) { $ model = new Measure ; $ model -> loadDefaultValues ( ) ; } else { $ model = $ this -> controller -> findModel ( $ id ) ; } $ isLoaded = $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) ; $ hasAccess = ( $ model -> isNewRecord && \ Yii :: $ app -> user -> can ( 'measure-create-measure' ) ) || ( ! $ model -> isNewRecord && \ Yii :: $ app -> user -> can ( 'measure-edit-measure' ) ) ; if ( $ isLoaded && ! $ hasAccess ) { throw new ForbiddenHttpException ; } if ( $ isLoaded && $ model -> save ( ) ) { return $ this -> controller -> redirect ( [ 'update' , 'id' => $ model -> id ] ) ; } else { return $ this -> controller -> render ( 'update' , [ 'hasAccess' => $ hasAccess , 'model' => $ model , ] ) ; } }
Updates an existing Measure model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
Updates an existing Measure model . If update is successful the browser will be redirected to the view page .