码迷,mamicode.com
首页 > 其他好文 > 详细

互相影响的选择

时间:2014-12-15 01:27:45      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:php

models
public function getLists($company_id = ''){
		$companye_model = Company::model()->findByPk($company_id);
		
		if($companye_model){
			$model = $this->model()->findAll(array(
					'condition' => 'pid=:pid',
					'params' 	=> array(':pid'=>$companye_model->id),
			));
		}else{
			$model = $this->model()->findAll();
		}

		if(is_null($model))
			return  null;

		$data = array();
		foreach ($model as $key => $value) {
			$data[$value->id] = $value->name;
		}
		return $data;
	}
$_form
<div class="row col-xs-8">
		<div class="col-xs-2">
			<?php echo $form->labelEx($model,'pid'); ?>
		</div>
        <div class="col-xs-9">
        <?php echo CHtml::dropDownList('CompanyProduct[pid]','CompanyProduct[pid]', Company::model()->getLists(), array(
            	'class'=>'form-control',
            	'ajax'=>array(
                'type'=>'GET',
                'url'=>CController::createUrl('/companyProduct/getType'),
                'update'=>'#CompanyProduct_typeid',
                'data'=>array('mid'=>"js:this.value",'typeid'=>1)
 
            ))
        ); ?>
        </div>
    </div>


	<div class="row col-xs-8">
		<div class="col-xs-2">
			<?php echo $form->labelEx($model,'typeid'); ?>
		</div>
		<div class="col-xs-9">
			<?php echo CHtml::activeDropDownList($model,'typeid',ProductType::model()->getLists(),array('class'=>'form-control')); ?>
			<?php echo $form->error($model,'typeid'); ?>
		</div>
	</div>
controller
public function actionGetType($mid){
		$results = ProductType::model()->getLists($mid);
		foreach ($results as $key => $value) {
			echo CHtml::tag('option', array('value'=>$key),CHtml::encode($value),true);
			# code...
		}
	}



互相影响的选择

标签:php

原文地址:http://blog.csdn.net/dapeng0112/article/details/41935869

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!