/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $oMarcas = Marca::model()->naoExcluido()->ordenarTitulo()->findAll(); $oCliente = Cliente::model()->findByPk($_GET['clienteId']); $oCores = Cor::model()->naoExcluido()->ordenarTitulo()->findAll(); if (isset($_POST['ClienteCarro'])) { $model->attributes = $_POST['ClienteCarro']; if ($model->save()) { if ($_POST['abrir_os'] == "true") { $this->redirect(array('ordemServico/create', 'clienteId' => $model->cliente_id, 'clienteCarroId' => $model->id)); } else { $this->redirect(array('cliente/view', 'id' => $model->cliente_id)); } } } $this->render('update', array('model' => $model, 'oMarcas' => $oMarcas, 'oCliente' => $oCliente, 'oCores' => $oCores)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Cor the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Cor::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }