I\'m trying to add a dropdown login form using Yii Bootstrap, like that attached tutorial, but I\'m not able to add HTML Form to TbNavbar items.
How ca
Move your button and form out of the TbMenu items array and into the TbNavbar items array. TbNavBar allows for html but not TbMenu.
<?php $this->widget('bootstrap.widgets.TbNavbar',array(
'items'=>array(
array(
'class'=>'bootstrap.widgets.TbMenu',
'htmlOptions'=>array('class'=>'pull-right'),
'items'=>array(
),
),
'<ul class="nav pull-right">
<li><a href="/users/sign_up">Sign Up</a></li>
<li class="divider-vertical"></li>
<li class="dropdown">
<a class="dropdown-toggle" href="#" data-toggle="dropdown">Sign In <strong class="caret"></strong></a>
<div class="dropdown-menu" style="padding: 15px; padding-bottom: 0px;">
<!-- Login form here -->
</div>
</li>
</ul>'
),
)); ?>
Additionally, to keep html markup to a minimum you can also use the 'template' array key:
<?php $this->widget('bootstrap.widgets.TbNavbar',array(
'items'=>array(
array(
'class'=>'bootstrap.widgets.TbMenu',
'htmlOptions'=>array('class'=>'pull-right'),
'items'=>array(
array('label'=>'Login', 'url'=>'#', 'visible'=>Yii::app()->user->isGuest, 'items'=>array(
array(
'label'=>'{menu}',
'template'=>'<form class="navbar-form pull-left" style="padding-left:15px;padding-right:15px;">
<input type="text" class="span2" placeholder="Login">
<input type="password" class="span2" placeholder="Password">
<button type="submit" class="btn">Submit</button>
</form>'
)
)),
),
),
))); ?>
Inside the defined template string you can also use the {menu} placeholder to be replaced with your link.