i create a gridview in Yii 2 like below :
<?= 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',
],
and i use my cutson setting for
'countryCode'=>[
'attribute'=>'countryCode',
'content' => function($model,$key,$index, $column) {
return Html::button($model->countryCode,$options = [
'onclick'=>'showcountryCode('.$key.')',
'id'=>'countryCode'.$key,
'class'=>'popup',
]);
}
],
you know we can have tags inside eachother in HTML like this :
<a> <h1> asdas </h1> </a>
now i want to put another tag inside Html::button
, how should i do that?
Definition of Html::button()
is
public static string button ($content = 'Button', $options = [])
so first parameter is anything you want to put inside.
You can use plain HTML
Html::button('<b>xxx</b><span>yyyy</span>');
or Yii 2 static Html
methods for the same custom tags:
Html::button(Html::tag('b', 'xxx') . Html::tag('span', 'yyyy'));