controllers/RegistrosController.php
/**
     * Creates a new Referencias model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Referencias model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Referencias model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new Registros();
        if ($model->load(Yii::$app->request->post())) {
            $datetime = new \DateTime('now');
            $now = $datetime->format('Y-m-d H:i:s');
            $model->pacientes_id = Yii::$app->session['idPaciente'];
            $model->users_id = Yii::$app->user->identity->id;
            $model->fecha = $now;
            if(!$model->save()) {
                \Yii::$app->session->setFlash('error', 'Algo falló, intente nuevamente');
            }
            return $this->redirect(['index']);
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
public function actionCreate ( ) { $ model = new Registros ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ datetime = new \ DateTime ( 'now' ) ; $ now = $ datetime -> format ( 'Y-m-d H:i:s' ) ; $ model -> pacientes_id = Yii :: $ app -> session [ 'idPaciente' ] ; $ model -> users_id = Yii :: $ app -> user -> identity -> id ; $ model -> fecha = $ now ; if ( ! $ model -> save ( ) ) { \ Yii :: $ app -> session -> setFlash ( 'error' , 'Algo falló, intente nuevamente') ; } return $ this -> redirect ( [ 'index' ] ) ; } return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; }
Creates a new Referencias model.
Creates a new Referencias model .