/** * 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 Maestrotipos the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Maestrotipos::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<div class="division"> <div class="row"> <?php echo $form->label($model, 'codigo'); ?> <?php echo $form->textField($model, 'codigo', array('size' => 8, 'maxlength' => 8)); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'codtipo'); ?> <?php $datos = CHtml::listData(Maestrotipos::model()->findAll(), 'codtipo', 'destipo'); echo $form->DropDownList($model, 'codtipo', $datos, array('empty' => '--Seleccione Tipo--', 'disabled' => '')); ?> <?php echo $form->error($model, 'codtipo'); ?> </div> <div class="row"> <?php echo $form->label($model, 'descripcion'); ?> <?php echo $form->textField($model, 'descripcion', array('size' => 60, 'maxlength' => 60)); ?> </div>
public function beforeSave() { if ($this->isNewRecord) { //$this->creadopor=Yii::app()->user->name; $this->codocu = '901'; //Si es un tipo de material que hereda el atributo ROTATIVO ///eNOTOICES COLOCARLO AUTOMATRICAMENTE if (Maestrotipos::model()->findBypK($this->codtipo)->esrotativo == '1') { $this->esrotativo = '1'; } //$g=new Numeromaximo; $this->codigo = Numeromaximo::numero($this, 'correl', 'maximovalor', 6, 'codtipo'); //$this->codigo='34343434'; } else { //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares; } return parent::beforeSave(); }