public function getTopButir() { $c = new CDbCriteria(); $c->condition = 'kegiatan_id = :kegiatan_id AND parent_id = :parent_id'; $c->params = array('kegiatan_id' => $this->id, 'parent_id' => 0); return ButirKegiatan::model()->findAll($c); }
echo $form->labelEx($model, 'kegiatan_id'); ?> <?php echo $form->dropDownList($model, 'kegiatan_id', CHtml::listData(Kegiatan::model()->findAll(), 'id', 'optionKegiatan')); ?> <?php echo $form->error($model, 'kegiatan_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'parent_id'); ?> <?php echo $form->dropDownList($model, 'parent_id', array_merge(array('--parent--'), CHtml::listData(ButirKegiatan::model()->findAll(), 'id', 'nama'))); ?> <?php echo $form->error($model, 'parent_id'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget(); ?>
/** * 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. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = ButirKegiatan::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }