SoFunction
Updated on 2025-04-04

Simple use of Yii2 tab

This article has shared the specific code used in the Yii2 tab for your reference. The specific content is as follows

<!--Tab Start-->
<?php
echo \yii\bootstrap\Tabs::widget([
'id' => 'tabs',
'renderTabContent' => false, //If you want to display custom DIV or Render other page files in each tab, set to false.'linkOptions' => ['data-toggle' => "tab"],
'items' => [
    [
'label' => Yii::t('app', 'Account Settings'),
'content' => '',
'headerOptions' => ["id" => 'li_account'], //Can be set or not'url' => '#tab_account',
'active' => true,
    ],
    [
'label' => Yii::t('app', 'Modify password'),
'content' => '',
'headerOptions' => ["id" => 'li_password'],
'url' => '#tab_password',
'active' => false,
    ],
    [
'label' => Yii::t('app', 'Binding Email'),
'content' => '',
'headerOptions' => ["id" => 'li_email'],
'url' => '#tab_email',
'active' => false,
    ]
  ]
]) ?>

<div class="tab-content">
  <!--Modify personal information-->
<div class="tab-pane active"> <!--IDIt should correspond to the above1indivual item ofURL-->
 content....
</div>
  <!--Modify password-->
<div class="tab-pane"> <!--IDIt should correspond to the above2indivual item ofURL-->
 content....
</div>
  <!--Bind the email-->
<div class="tab-pane"> <!--IDIt should correspond to the above3indivual item ofURL-->
 content....
</div>
</div>

<!--Tab End-->

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.