public function actionGetLevelObjs() { $designation_type_id = $_POST['Designation']['designation_type_id']; $level = Designation_types::model()->findByPk($designation_type_id)->level; $levelobjs = $level::model()->findAll(); foreach ($levelobjs as $levelobj) { //$level=$designation->level; //$name = $level::model()->findByPk($designation->id)->name; echo CHtml::tag('option', array('value' => $levelobj->id), CHtml::encode($levelobj->name), true); } /* foreach($data as $value=>$name) { echo CHtml::tag('option', array('value'=>$value),CHtml::encode($name),true); } */ }
/** * 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 = Designation_types::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'instructions-form', 'enableAjaxValidation' => false)); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php foreach (Designation_types::model()->findAll() as $model1) { $listData[$model1->id] = $model1->name; } $from = Designation::model()->findByAttributes(array('user' => Yii::app()->user->id))->id; ?> <table> <tr> <td> <div class="row"> <?php echo $form->labelEx($model, 'to'); ?> <?php echo CHtml::dropDownList("designation_type", '', $listData, array('ajax' => array('type' => 'POST', 'url' => CController::createUrl('issues/getLevelDetails'), 'update' => '#Instructions_to'))); ?> <?php echo $form->dropDownList($model, 'to', array());
<?php $form = $this->beginWidget('CActiveForm', array('id' => 'designation-form', 'enableAjaxValidation' => false)); ?> <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, 'designation_type_id'); ?> <?php echo $form->dropDownList($model, 'designation_type_id', CHtml::listData(Designation_types::model()->findAll(), 'id', 'name'), array('ajax' => array('type' => 'POST', 'url' => CController::createUrl('designation/getLevelObjs'), 'update' => '#Designation_level_id'))); ?> <?php echo $form->error($model, 'designation_type_id'); ?> </div> <div class="row"> <?php echo CHtml::label('Place of Posting', 'Designation_level_id'); ?> <?php