/** * 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 JenisBarang the loaded model * @throws CHttpException */ public function loadModel($id) { $model = JenisBarang::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php $form = $this->beginWidget('CActiveForm', array('id' => 'barang-form', 'enableAjaxValidation' => true, 'enableClientValidation' => true, 'clientOptions' => array('validateOnType' => true, 'validationOnChange' => true))); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'jenis_barang'); ?> <?php echo $form->dropDownList($model, 'jenis_barang', CHtml::listData(JenisBarang::model()->findAll(), 'id', 'jenis_barang'), array('prompt' => '= Pilihan =', 'style' => 'width:200px;')); ?> <?php echo $form->error($model, 'jenis_barang'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'nama_barang'); ?> <?php echo $form->textField($model, 'nama_barang', array('size' => 40, 'maxlength' => 40)); ?> <?php echo $form->error($model, 'nama_barang');