2016-10-04 25 views
0

我創建的Yii 2 GridView中象下面這樣:與HTML :: Yii中按鈕的工作2

<?= GridView::widget([ 
     'dataProvider' => $dataProvider, 
     'filterModel' => $searchModel, 
     'columns' => [ 
      ['class' => 'yii\grid\ActionColumn'], 
      ['class' => 'kartik\grid\SerialColumn'], 
      ['class' => 'kartik\grid\CheckboxColumn'], 
      'id', 
      'countrydate', 
      'countryCode'=>[ 
       'attribute'=>'countryCode', 
       'content' => function($model,$key,$index, $column) { 
        return Html::button($model->countryCode,$options = [ 
         'onclick'=>'showcountryCode('.$key.')', 
         'id'=>'countryCode'.$key, 
         'class'=>'popup', 
        ]); 
       } 
      ], 
      'countryName', 
      'countrydate', 
      'population', 
      'fipsCode', 

     ], 

,我用我的cutson設置爲

'countryCode'=>[ 
        'attribute'=>'countryCode', 
        'content' => function($model,$key,$index, $column) { 
         return Html::button($model->countryCode,$options = [ 
          'onclick'=>'showcountryCode('.$key.')', 
          'id'=>'countryCode'.$key, 
          'class'=>'popup', 
         ]); 
        } 
       ], 

你知道我們可以有內部標籤海誓山盟在這樣的HTML:

<a> <h1> asdas </h1> </a> 

現在我想提出另一個標籤內Html::button,我應該怎麼做呢?

回答

0

Html::button()定義是

public static string button ($content = 'Button', $options = []) 

所以第一個參數是你想要把裏面東西。

您可以使用純HTML的相同的自定義標籤

Html::button('<b>xxx</b><span>yyyy</span>'); 

或Yii的2種靜態Html方法:

Html::button(Html::tag('b', 'xxx') . Html::tag('span', 'yyyy'));