/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Preferencia(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Preferencia'])) { $model->attributes = $_POST['Preferencia']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $modelUsuario = new Usuario(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($modelUsuario); if (isset($_POST['Usuario'])) { $modelUsuario->attributes = $_POST['Usuario']; $modelUsuario->orgao_id = 1; $modelUsuario->senha = md5(SALT_MD5 . $_POST['Usuario']['senha']); //$modelUsuario->senha = md5(SALT_MD5 . $_POST['Usuario']['senha']); $modelUsuario->data_cadastro = date('Y-m-d'); $modelUsuario->avatar = CUploadedFile::getInstance($modelUsuario, 'avatar'); if ($modelUsuario->save()) { // PreferĂȘncia $modelPreferencia = new Preferencia(); } $modelPreferencia->usuario_id = $modelUsuario->id; $modelPreferencia->save(); $this->redirect(array('admin', 'id' => $modelUsuario->id)); } $this->render('create', array('model' => $modelUsuario)); }