如何在Yii2中自定义Navbar属性

时间:2015-10-27 13:44:01

标签: css twitter-bootstrap-3 yii2-advanced-app

我有这样的导航标题:

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container-fluid">
    <div class="navbar-collapse collapse">
      <form class="navbar-form navbar-right" role="search">
        <div class="form-group has-feedback">
            <input id="searchbox" type="text" placeholder="Search" class="form-control">
            <span id="searchicon" class="fa fa-search form-control-feedback"></span>
        </div>
      </form>
    </div><!--/.navbar-collapse -->
  </div>
</div>

当我想使用yii\bootstrap\NavBar;转换此代码时遇到问题:

<div class="navbar-collapse collapse">
     <form class="navbar-form navbar-right" role="search">
           <div class="form-group has-feedback">
                <input id="searchbox" type="text" placeholder="Search" class="form-control">
                <span id="searchicon" class="fa fa-search form-control-feedback"></span>
            </div>
      </form>
</div><!--/.navbar-collapse -->

这是Layout使用yii\bootstrap\NavBar;的代码:

<?php
    NavBar::begin([
        'brandLabel' => 'My Company',
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar navbar-inverse navbar-fixed-top',
            'role' => 'navigation',
        ],
    ]);
    NavBar::end();
?>

我已经阅读了Navbar Widget,但仍然不明白。是否有人可以教我在Navbar上使用Yii2 framework小部件?

1 个答案:

答案 0 :(得分:5)

好的,这里是代码,在这里我只是放置undefined来自你发布的问题,我猜你知道如何在导航栏中searchbox其他菜单链接

无论如何它就像这样

echo