Ejemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Utenti();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Utenti'])) {
         $model->attributes = $_POST['Utenti'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 2
0
 /**
  * Esegue la registrazione del nuovo utente all'interno del db.
  * @return boolean : true se riesce a registrarlo
  */
 public function save()
 {
     /* Questa funzione � esposta pubblicamente e messa a disposizione
      * di chiunque volesse memorizzare una nuova utenza su db
      */
     //creo un AR e indico che voglio lavorare con lo scenario register
     $utente = new Utenti('register');
     //Dato che i campi del modello User si chiamano quasi tutti come quelli di questa classe,
     //posso permettermi il lusso di fare cos�:
     $utente->attributes = $this->attributes;
     //passo tutti i campi del modello all'active record
     //l'unico campo che si chiama diversamente � questo:
     // $utente->remember = $this->rememberMe;
     //$utente->amministratore_id = Yii::app()->user->id;
     $utente->id_amministratore = Yii::app()->user->id;
     //provo a salvare e restituisco l'esito del risultato
     return $utente->save();
 }