2013-07-08 3 views

답변

0

당신은 또한 부트 스트랩

$this->widget('bootstrap.widgets.TbButtonGroup', array(
    'type' => 'primary', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse' 
    'buttons' => array(
        array('label' => 'Action', 'url' => '#'), // this makes it split :) 
        array('items' => array(
        array('label' => 'Action', 'url' => '#'), 
        array('label' => 'Another action', 'url' => '#'), 
        array('label' => 'Something else', 'url' => '#'), 
        array('label' => 'Separate link', 'url' => '#'), 
    )), 
    ), 

))에서 버튼의 드롭 다운 메뉴를 사용할 수 있습니다;

또는 Navbar의 메뉴에서이 같은 하위 메뉴를 추가 할 수 있습니다 ..

array('label'=>'First Link', 'url'=>"#", 'itemOptions'=>array('id' => 'xyz')) 
1

이 내가

다음과 같은 설정 (모델 이름 TblUser입니다) 사용자 테이블이 구문 http://www.cniska.net/yii-bootstrap/

 <div class="btn-toolbar"> 
      <?php 
      $this->widget('bootstrap.widgets.TbButtonGroup', array(
       'type' => 'primary', 
       'buttons' => array(
        array('label' => 'Action', 'items' => array(
          array('label' => 'Action', 'url' => '#'), 
          array('label' => 'Another action', 'url' => '#'), 
          array('label' => 'Something else', 'url' => '#'), 
          array('label' => 'Separate link', 'url' => '#'), 
        )), 
       ), 
      )); 
      ?> 
     </div> 

기본이다

예 :

사용자 목록을 드롭 다운으로 표시하고 싶을 때 링크를 선택하면 해당 사용자 프로필로 이동해야합니다.

 <?php 
     $usersAry = CHtml::listData(TblUser::model()->findAll(array('order' => 'id')), 'id', 'username'); 

     //$usersAry comes with id as key and username as value 
     //echo "<pre>"; 
     //print_r($usersAry); 
     //echo "</pre>"; 

     $items=array(); 
     foreach ($usersAry as $userId=>$user) 
     { 
      $items[]=array('label'=>$user,'url'=>'/user/view/'.$userId); 
     } 
     ?> 

     <div class="btn-toolbar"> 
      <?php 
      $this->widget('bootstrap.widgets.TbButtonGroup', array(
       'type' => 'primary', 
       'buttons' => array(
        array('label' => 'User List', 'items' => $items), 
       ), 
      )); 
      ?> 
     </div> 
관련 문제