E
E
EvgMul2017-03-28 13:20:13
Yii
EvgMul, 2017-03-28 13:20:13

How to make Html be processed in Yii2 and not displayed on the screen?

Hello. The problem is the following: there is a main menu of the site, it is generated approximately as follows:

NavBar::begin([
        'brandLabel' => '',
        'brandUrl' => '#',
        'options' => [
            'class' => 'navbar-default front-navbar',
        ],
    ]);
    
    $label = 'test';
   
    
    $menuItems = [
        [
            'label' => $label,
            'url' => '#',
            'linkOptions' => [
                'value' => Url::to(['default/show-cities',]), 
                'title' => 'Выберите город', 
                'class' => 'showModalButton',
                'id' => 'choice-city-link',
            ]
        ],
        ];
    
    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-left'],
        'items' => $menuItems,
    ]);
    NavBar::end();
    ?>

I want before $label(or in it) to interpose <span>with the text. But the trouble is that the tag code is displayed on the page. Tried Html::encode(), didn't help. This one turns out to be inside , perhaps because of this, although, as far as I know, you can put tags in. Please tell me how can I solve this problem? Thanks in advance to all who respond. <a><a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lem_prod, 2017-03-28
@EvgMul

$menuItems = [
        [
            'encode' => false,
            'label' => '<strong>Label</strong>',
            'url' => '#',
            'linkOptions' => [
                'value' => Url::to(['default/show-cities',]), 
                'title' => 'Выберите город', 
                'class' => 'showModalButton',
                'id' => 'choice-city-link',
            ]
        ],
        ];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question