/** * 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); $oModelos = Modelo::model()->ordenarTitulo()->naoExcluido()->findAll(); $oMarcas = Marca::model()->ordenarTitulo()->naoExcluido()->findAll(); $oTiposProduto = TipoProduto::model()->ordenarTitulo()->naoExcluido()->findAll(); if (isset($_POST['Produto'])) { $model->attributes = $_POST['Produto']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model, 'oModelos' => $oModelos, 'oMarcas' => $oMarcas, 'oTiposProduto' => $oTiposProduto)); }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = Modelo::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionGetDataJson() { $array = array(); $oModelos = Modelo::model()->naoExcluido()->ordenarTitulo()->findAllByAttributes(array('marca_id' => $_POST['marcaId'])); $i = 0; foreach ($oModelos as $modelo) { $array[$i]['id'] = intval($modelo->id); $array[$i]['text'] = $modelo->titulo; $i++; } echo json_encode($array); }
$("#Order_equipment_type_id").children().remove(); $("#Order_equipment_type_id").append( new Option("Seleccionar")); $("#Order_brand_id > option[value=]").attr("selected","selected"); }'))); ?> <?php echo $form->error($model, 'brand_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'model_id'); ?> <?php echo $form->dropDownList($model, 'model_id', CHtml::listData(Modelo::model()->findAll(array('condition' => 'active=1', 'order' => 'name')), 'id', 'name'), array('prompt' => 'Seleccionar')); ?> <?php echo $form->error($model, 'model_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'service_type_id'); ?> <?php echo $form->dropDownList($model, 'service_type_id', CHtml::listData(ServiceType::model()->findAll(array('condition' => 'active=1', 'order' => 'name')), 'id', 'name'), array('prompt' => 'Seleccionar', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('order/servicesFromServiceType'), 'data' => array('Order[service_type_id]' => 'js:this.value'), 'success' => 'js:function(dataType){ jsonObject = JSON.parse(dataType); $("#Order_service").children().remove();
public function actionModelsFromBrand() { if (isset($_POST['Order']['brand_id'])) { $models = Modelo::model()->findAll(array('condition' => 'brand_id = :brand_id AND equipment_type_id=:equipment_type_id ', 'order' => 'name', 'params' => array(':brand_id' => $_POST['Order']['brand_id'], ':equipment_type_id' => $_POST['Order']['equipment_type_id']))); $this->renderPartial('modelsFromBrand', array('models' => $models)); } }