2

I use DetalView widget and I need <ВR> tag:

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

getUserAttributes returns string:

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

If instead of comma input <ВR>, then text will be like this: "text.. <ВR> ..text"

3 Answers 3

5

Try this

...........

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

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

The "raw" format tells Yii2 not to do anything with the output. So it will display any html tag.

Sign up to request clarification or add additional context in comments.

Comments

1

You need to try to use format property like as 'formate' => 'text'.

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

Comments

0

You can use $string .= nl2br($item[$field]).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.