backend/controllers/NewsController.php
/**
     * Creates a new News model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new News model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new News model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new News();
        if ($model->load(Yii::$app->request->post())) {
            if ($model->save()) {
                Yii::$app->session->setFlash('success', 'News successfuly created.');
                return $this->redirect(['view', 'id' => $model->news_id]);
            } else {
                Yii::$app->session->setFlash('danger', 'There was an error on creating News.' . $model->getErrors());
            }
        }
        $model->news_status = $model::STATUS_ACTIVE;
        return $this->render('create', [
            'model' => $model,
        ]);
    }
public function actionCreate ( ) { $ model = new News ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ model -> save ( ) ) { Yii :: $ app -> session -> setFlash ( 'success' , 'News successfuly created.' ) ; return $ this -> redirect ( [ 'view' , 'id' => $ model -> news_id ] ) ; } else { Yii :: $ app -> session -> setFlash ( 'danger' , 'There was an error on creating News.' . $ model -> getErrors ( ) ) ; } } $ model -> news_status = $ model :: STATUS_ACTIVE ; return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; }
Creates a new News model.
Creates a new News model .