Yii - Linked drop-down menu, can be multi-level_PHP tutorial

WBOY
Release: 2016-07-14 10:09:25
Original
877 people have browsed it

view file

[html]
getMemGroup(),array(
'class'=>'s_ipt w_120',
'empty'=>'Please select a member group',
'ajax' =>array(
                'type'=>'GET',  
                'url'=>CController::createUrl('cmpTemplates/getMemType'),  
                'update'=>'#CmpTemplates_zmg_ids',
'data' = & gt; array ('mid' = & gt; "js: this.value")
            ),
))?>
dropDownList($model,'zmg_ids',array(),array('class'=>'s_ipt w_120','empty'=>'Select membership level' ))?>
Controller
[html]
/**
* Get the membership group and the corresponding membership level for use in the drop-down menu
*/
public function actionGetMemType($mid=0)
{
$criteria=new CDbCriteria;
$criteria->compare('zmg_id',$mid);
$memType = MemType::model()->findAll($criteria);
$name = 'Select membership level';
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);
}
}
Model
[html]
/*
* Get member group information
*/
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];
} }
}
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477691.htmlTechArticleView file [html] ?php echo CHtml::activeDropDownList($model,zmg_id,MemGroup::model() -getMemGroup(),array( class=s_ipt w_120, empty=Please select a member group, ajax =array( type=GET, url=...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!