视图文件
[html]
getmemgroup(),array(
'class'=>'s_ipt w_120',
'empty'=>'请选择会员组',
'ajax' =>array(
'type'=>'get',
'url'=>ccontroller::createurl('cmptemplates/getmemtype'),
'update'=>'#cmptemplates_zmg_ids',
'data'=>array('mid'=>js:this.value)
),
))?>
dropdownlist($model,'zmg_ids',array(),array('class'=>'s_ipt w_120','empty'=>'选择会员等级'))?>
控制器
[html]
/**
* 获取会员组,对应的会员等级,用于下拉菜单
*/
public function actiongetmemtype($mid=0)
{
$criteria=new cdbcriteria;
$criteria->compare('zmg_id',$mid);
$memtype = memtype::model()->findall($criteria);
$name = '选择会员等级';
echo chtml::tag('option', array('value'=>0), $name, true);
foreach($memtype as $val) {
echo chtml::tag('option', array('value'=>$val->zmt_id),chtml::encode($val->zmt_title),true);
}
}
模型
[html]
/*
* 取会员组信息
*/
public function getmemgroup($type=null){
if($type==null){
$criteria=new cdbcriteria;
$criteria->compare('type','1');
$memgroup = memgroup::model()->findall($criteria);
return chtml::listdata($memgroup,'zmg_id','zmg_title');
}else{
$level = $this->getmemgroup();
if(array_key_exists($type,$level)){
return $level[$type];
}
}
}
http://www.bkjia.com/phpjc/477691.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/477691.htmltecharticle视图文件 [html] ?php echo chtml::activedropdownlist($model,zmg_id,memgroup::model()-getmemgroup(),array( class=s_ipt w_120, empty=请选择会员组, ajax =array( type=get, url=...