2016-07-22 5 views
0

Html :: ul()メソッドにクラスを追加する方法。 Html :: ul()メソッドにクラスを追加します。

<?= Html::ul($posts, ['item' => function($item, $index) { 
    return Html::tag(
     'li', 
     $this->render('post', ['item' => $item]), 
     ['class' => 'post'] 
    ); 
}], [ 'class' => 'myclass' ]) ?> 

しかし、それは次のように、ULのレンダリングだ:私はコードの下にしようとした

<?= Html::ul($posts, ['item' => function($item, $index) { 
    return Html::tag(
     'li', 
     $this->render('post', ['item' => $item]), 
     ['class' => 'post'] 
    ); 
}]) ?> 

<ul 0-class="myclass"> 

何もyii2 documentで言及されていない私は、次のコードを持っています。

助けがあれば助かります。ありがとう。

答えて

1

以下のコードが機能しました!誰かに役立つかもしれない。

echo Html::ul($posts, ['item' => function($item, $index) { 
      return Html::tag(
       'li', 
       $this->render('post', ['item' => $item]), 
       ['class' => 'post'] 
      ); 
     }, 'class' => 'myclass']); 
関連する問題