2016-10-04 1 views
0

i erstellen gridview in Yü 2 wie unten:Arbeit mit HTML :: Taste in Yü 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', 

     ], 

und ich verwende meine cutson Einstellung für

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

wissen Sie, wir Tags innerhalb haben einander in HTML wie folgt aus:

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

jetzt will ich innerhalb Html::button einen anderen Tag legen, wie soll ich das tun?

Antwort

0

Definition von Html::button() ist

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

so erste Parameter alles, was Sie wollen, ist nach innen setzen.

Sie können mit einfachen HTML

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

oder Yü 2 statische Html Methoden für die gleichen benutzerdefinierten Tags:

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