Skip to content
Advertisement

How can i add title attributes in links using the Yii2 framework?

I created a navigation menu in yii2 and i have links generated by the following code:

  <?= HeaderNavigation::widget([
                'options' => ['class' => 'nav nav-tabs border-0 flex-column flex-lg-row'],
                'itemOptions' => [
                    'class' => 'nav-item',
                ],
                'items' => [
                    [
                        'label' => Yii::t('lang', 'Browse'),
                        'url' => ['directory/index'],
                        'icon' => 'home',
                        'title' => 'HELLO WORLD'
                    ],
                    
                ],
            ]) ?>

but title attribute doesn’t work. What i m doing wrong??

Advertisement

Answer

OK, finally i managed to make it work with the help of Michal HynĨica.

I had to use options key:

'options' => ['title' => 'HELLO WORLD'],

so the code should be:

'items' => [
                    [
                        'options' => ['title' => 'HELLO WORLD'],
                        'label' => Yii::t('lang', 'Browse'),
                        'url' => ['directory/index'],
                        'icon' => 'home',
                        'title' => 'HELLO WORLD'
                    ],
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement