/** * 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 TbpOutputItem the loaded model * @throws CHttpException */ public function loadModel($id) { $model = TbpOutputItem::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php echo CHtml::dropDownList('TbpOutputLog[' . $i . '][mainid]', $array[$i]->mainid, CHtml::listData(TbpOutputMain::model()->findAll(array('order' => 'id ASC', 'condition' => 'opt1=1')), 'id', 'cname'), array("disabled" => $array[$i]->opt1 == 0 ? "disabled" : '', 'prompt' => '選擇主項', 'options' => array($array[$i]->mainid => array('selected' => 'selected')), 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('tbpOutputStore/dynamicoutputsubs', array('index' => $i)), 'update' => '#TbpOutputLog_' . $i . '_subid'))); ?> </td> <td> <?php echo CHtml::dropDownList('TbpOutputLog[' . $i . '][subid]', $array[$i]->subid, CHtml::listData(TbpOutputSub::model()->findallByAttributes(array('id' => $array[$i]->subid ? $array[$i]->subid : '')), 'id', 'cname'), array("disabled" => $array[$i]->opt1 == 0 ? "disabled" : '', 'options' => array($array[$i]->subid => array('selected' => 'selected')), 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('tbpOutputStore/dynamicoutputitems', array('index' => $i)), 'update' => '#TbpOutputLog_' . $i . '_itemid'))); ?> </td> <td> <?php echo CHtml::dropDownList('TbpOutputLog[' . $i . '][itemid]', $array[$i]->itemid, CHtml::listData(TbpOutputItem::model()->findallByAttributes(array('id' => $array[$i]->itemid ? $array[$i]->itemid : '')), 'id', 'cname'), array("disabled" => $array[$i]->opt1 == 0 ? "disabled" : '', 'options' => array($array[$i]->itemid => array('selected' => 'selected')), 'ajax' => array('url' => CController::createUrl('tbpOutputStore/dynamictype', array('index' => $i)), 'data' => array('TbpOutputLog[' . $i . '][itemid]' => 'js:this.value'), 'success' => 'function(data){ $("#opTypeBlock' . $i . '").html(data); }'))); ?> </td> <!--<td>--> <input type="hidden" name=<?php echo "TbpOutputLog[{$i}][id]"; ?> value="<?php echo $array[$i]->id; ?> " /> <?php // echo CHtml::dropDownList('TbpOutputLog['.$i.'][type]',$array[$i]->type,array('1'=>'type1','2'=>'type2','3'=>'type3'),array(
public function actionDynamictype() { $row = ''; $itemname = ''; if (isset($_GET['index'])) { $row = $_GET['index']; } if (isset($_GET['TbpOutputLog'][$row]['itemid'])) { $itemid = $_GET['TbpOutputLog'][$row]['itemid']; } // 由異動欄位來的值 //依傳入之mainid來查詢對應次項, 並且要已啟用 $item = TbpOutputItem::model()->findByAttributes(array(), $condition = "id = :id and opt1 = '1' order by id ", $params = array(':id' => $itemid)); // 依傳入之$item[0]->subid來查詢對應次項, 並且要已啟用 // $summary = TbpOutputSub::model()->findAllByAttributes( // array(), // $condition = "id = :id and opt1 = '1' ", // $params = array( // ':id'=>(int) $item[0]->subid, // ) // ); $model = new TbpOutputLog(); $this->renderPartial('_type' . $item->type, array('model' => $model, 'row' => $row, 'summary' => $item->summary), false, true); }