Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
giles

Adding An Argument To Bootstrap Form

Recommended Posts

Hi,

 

I'm working through chapter 13, adding yii-booster nav bar to my Yii development. I hope its appropriate to ask this question here (apologies in advance if it is not). I have a simplified version below. I basically want to add a visibility argument to the search form. It's wrong, but i've included it to try illustrate what I'm after. Am I unable to add and if inside and array?

'items'=>array(
    
    // L/H menu
    array(
        'class'=>'bootstrap.widgets.TbMenu',
        'items'=>array(
            // GUESTS
            array('label'=>'Log In', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
            // USERS
            array('label'=>'Subject', 'url'=>'#', 'visible'=>!Yii::app()->user->isGuest, 'items'=>array(
                array('label'=>'YOUR BROWSING TODAY'),
                array('label'=>'My Body - Fitness - Programs', 'url'=>'#'),
                array('label'=>'My Body - Fitness - Motivation', 'url'=>'#'),
            )),
            // end (always visible)
            array('label'=>'Contact', 'url'=>array('/site/contact')),
        ),
    ),
    
    // search field
    if(!Yii::app()->user->isGuest) echo ''<form class="navbar-search pull-left" action=""><input type="text" class="search-query span2" placeholder="Search" ></form>''; ,

),

Share this post


Link to post
Share on other sites

Actually this should work fine as you have it, works for me

'visible'=>!Yii::app()->user->isGuest,

or

'visible'=> (Yii::app()->user->isGuest) ? false : true,
  • Upvote 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...