Updates an existing CommentModel model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
553385
public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        // if the model has an anonymousUsername value
        // we will consider it as an anonymous message
        if (!is_null($model->anonymousUsername))
        {
            $model->scenario = $model::SCENARIO_ANONYMOUS;
        }


        if ($model->load(Yii::$app->request->post()) && $model->save())
        {
            Yii::$app->session->setFlash('success', Yii::t('app', 'Comment has been saved.'));

            return $this->redirect(['index']);
        }

        return $this->render($this->updateView, [
            'model' => $model,
        ]);

    }
875714
public function update($id)
    {
        try
        {
            $update = $this->repo->update($id, Input::all());
        } catch (ValidationErrorException $exception)
        {
            return $this->respondNotValid($exception);
        }

        if ( ! $update)
        {
            return $this->respondNotFound();
        }

        $item = $this->repo->getById($id);

        return $this->response->item($item, new $this->transformerClass);
    }
393473
public function actionUpdate($id)
    {
        if (request()->post('_asnew') == '1') {
            $model = new User();
        }else{
            $model = $this->findModel($id);
        }

        if (!is_role('admin')) {
            throw new \yii\web\HttpException(403, t('app', 'You are not allowed to perform this action.'));
        }

        if ($model->loadAll(request()->post())) {
            if ($model->saveAll()) {
                set_flash_has_been_saved();
                return $this->redirect(['update', 'id' => $model->id]);
            } else {
                set_flash_has_not_been_saved();
            }
        }

        return $this->render('update', [
            'model' => $model,
        ]);
    }
720196
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']);
        }
    }
624682
protected function __apiUpdate(string $id)
    {
        $record = HCPages::findOrFail($id);

        $data = $this->getInputData();

        $record->update(array_get($data, 'record'));
        $record->updateTranslations(array_get($data, 'translations'));
        $record->categories()->sync(array_get($data, 'categories', []));
        $record->removeCachedMenu();

        return $this->apiShow($record->id);
    }
66406
public function update($id)
    {
        /** @var FormRequest $request */
        $request = app($this->getUpdateRequestClass());
        $record  = $this->modelRepository->findOrFail($id);

        $data = $request->only($this->getRelevantFormFieldKeys());

        /** @var FormDataStorerInterface $storer */
        $storer = app(FormDataStorerInterface::class);
        $storer->setModelInformation($this->getModelInformation());

        if ( ! $storer->store($record, $data)) {
            // @codeCoverageIgnoreStart
            return redirect()->back()
                ->withInput()
                ->withErrors([
                    static::GENERAL_ERRORS_KEY => [ $this->getGeneralStoreFailureError() ],
                ]);
            // @codeCoverageIgnoreEnd
        }

        $this->storeActiveTab($request->input(static::ACTIVE_TAB_PANE_KEY));

        cms_flash(
            cms_trans(
                'models.store.success-message-edit',
                [ 'record' => $this->getSimpleRecordReference($id, $record) ]
            ),
            FlashLevel::SUCCESS
        );

        event( new Events\ModelUpdatedInCms($record) );

        if ($request->input(static::SAVE_AND_CLOSE_KEY)) {
            return redirect()->route("{$this->routePrefix}.index");
        }

        return redirect()->route("{$this->routePrefix}.edit", [ $record->getKey() ]);
    }
208693
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        if ($model->isAuthor) {
            if ($model->load(Yii::$app->request->post()) && $model->save()) {
                Yii::$app->getSession()->setFlash('success', Yii::t('article', 'Article updated.'));
                return $this->redirect(['view', 'uuid' => $model->uuid]);
            }
            return $this->render('update', ['model' => $model]);
        }
        throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.'));
    }
583399
public function update($id)
    {
        $return = [];
        $class = $this->model;

        $this->input['id'] = $id;
        $this->validate(request(), $this->getValidationRules());

        $model = $class::find($id);
        if ($this->canEdit($model)) {
            $this->fillModel($model);

            $return = $model->push()
                ? ['success' => ucfirst($this->readableResourceType()) . ' updated successfully.']
                : ['error' => 'There was a problem saving the ' . $this->readableResourceType() . '.'];
        } else {
            $return = [
                'error' => 'You don\'t have permission to edit this '
                    . $this->readableResourceType() . '.'
            ];
        }

        return $return;
    }
456232
public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', '修改成功');
            return \myzero1\layui\helpers\Tool::redirectParent(['index']);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
774941
private function updatePost($id)
	{
		$model = $this->loadModel($id);

		if (!$this->user->role->hasPermission('modify'))
			throw new CHttpException(403, Yii::t('Api.content', 'You do not have permission to create new entries.'));

		if ($this->user->role->isA('author') || $this->user->role->isA('collaborator'))
			$model->author_id = $this->user->id;

		$vid 	= $model->vid;
		$model 	= new Content;
		$model->id = $id;
		$model->populate($_POST);
		$model->vid = Yii::app()->db->createCommand('SELECT MAX(vid)+1 FROM content WHERE id = :id')->bindParam(':id', $id)->queryScalar();

		if ($model->save())
			return $model->getAPIAttributes(array(
					'category_id',
					'parent_id',
					'author_id'
				),
				array(
					'author' => array(
						'password',
						'activation_key',
						'email',
						'about',
						'user_role',
						'status',
						'created',
						'updated'
					),
					'category' => array(
						'parent_id'
					),
					'metadata' => array(
						'content_id'
					)
				));

		return $this->returnError(400, NULL, $model->getErrors());
	}
1210143
public function update($id)
    {
        $content = $this->repository->getById($id);
        if (!empty($content)) {
            $this->authorize('update', $content);
            $input   = $this->validator->validate('update');
            $content = $this->repository->update($content, $input, auth()->user());
            return $this->respondWithSuccess($content, new ContentTransformer);
        }
        return $this->respondNotFound();
    }
154199
public function actionDelete($id)
    {
        if ($this->findModel($id)->deleteComment()) {
            return Yii::t('app', 'Comment was deleted.');
        } else {
            Yii::$app->response->setStatusCode(500);

            return Yii::t('app', 'Comment has not been deleted. Please try again!');
        }
    }
1226662
public function save($id = null): Model
	{
		$id = $id ?? $this->getInputId();

		if ($id) {
			return $this->update($id);
		}

		return $this->create();
	}
42978
public function actionUpdate($id)
    {
        $user = $this->findModel($id);
        $model = new MultiModel([
            'models' => [
                'user' => $user,
                'profile' => $user->profile,
            ],
        ]);
        $model->getModel('user')->setScenario('backend');

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            switch (Yii::$app->request->post('redirect')) {
                case 'exit':
                    return $this->redirect(['index']);
                case 'new':
                    return $this->redirect(['create']);
                default:
                    return $this->redirect(['view', 'id' => $model->getModel('user')->id]);
            }
        } else {
            return $this->render('update', [
                'model' => $model,
                'roles' => ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'description'),
            ]);
        }
    }
145868
public function getUpdate($id)
    {
        return $this->send($this->getHttp()->get($this->url.'updates/'.$id.'.json'));
    }
1236389
public function run($id)
    {
        $model = $this->getModel($id);

        if ($model->{$this->methodName}()) {
            $this->addSuccessFlash();
        }

        return $this->redirect($model);
    }
1067870
public function update($id)
    {
        $user = $this->userRepo->getById($id);
        if (!empty($user)) {
            $this->authorize('update', $user);
            $input = $this->validator->bind('nick', ['user_id' => $user->id])->bind('email', ['user_id' => $user->id])
                ->validate('update');
            $user  = $this->userRepo->update($user, $input);
            return $this->respondWithSuccess($user, new UserTransformer());
        }
        return $this->respondNotFound();
    }