Commit 934dd3a1 authored by Shakarim Sapa's avatar Shakarim Sapa

- Добавлено редактирование данных

parent 860224b5
......@@ -13,6 +13,7 @@ use common\components\AdminController;
use common\modules\blog\models\BlogBids;
use yii\data\ActiveDataProvider;
use Yii;
use yii\web\NotFoundHttpException;
class BidAdminController extends AdminController {
public static function actionsTitles(){
......@@ -66,4 +67,43 @@ class BidAdminController extends AdminController {
]
);
}
/**
* @param $id
* @return string|\yii\web\Response
*/
public function actionUpdate($id){
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post())) {
$datetime=new \DateTime();;
$model->date=$datetime->format('Y-m-d H:i:s');
if ($model->save())
return $this->redirect([
'manage'
]);
} else {
$form = new \common\components\BaseForm('/common/modules/blog/forms/BidForm', $model);
return $this->render(
'update',
[
'form' => $form
]
);
}
}
/**
* @param $id
* @return null|BlogBids
* @throws NotFoundHttpException
*/
protected function findModel($id)
{
if (($model = BlogBids::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
\ No newline at end of file
<?php
echo $form->out;
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment