2016-03-28 5 views
2

htmlタグ付き出力テキストにどのように:DetalView Yii2:私はDetalViewウィジェットを使用して、私は<ВR>タグ必要

$string .= $item[$field] . ", "; 

代わりにコンマ入力<ВRの場合:

<?= DetailView::widget([ 
     'model' => $model, 
     'attributes' => [ 
      'information:ntext',     
      [ 
       'attribute' => 'text', 
       'value' => $model->getUserAttributes('getScientificWorks', 'text'), 
      ], 
     ], 
    ]) 
    ?> 

getUserAttributesは、文字列を返します>の場合、テキストは次のようになります。 "テキスト.. <ВR> ..テキスト"

答えて

3

"生" の形式は、出力と何かをしないように指示しますYii2この

........... 

    [ 
     'attribute' => 'text', 
     'value' => $model->getUserAttributes('getScientificWorks', 'text'), 
     'format' => 'raw', 
    ], 

............ 

を試してみてください。したがって、任意のhtmlタグが表示されます。

1

formatのようなプロパティを使用する必要があります'formate' => 'text'

........ 
     [ 
      'attribute' => 'text', 
      'value' => $model->getUserAttributes('getScientificWorks', 'text'), 
      'format' => 'text', 
     ], 
    ......... 
0

$string .= nl2br($item[$field])を使用できます。

関連する問題