[EXTENSION] Bootstrap

@Daniel: Thanks for the fix, I’ll give that a try very soon.

@dstudio: Does any other widget work for you? if not, I think you have to look at your setup config/main.php.

Hi,

I’ve just tried to upgrade from Bootstrap 0.9.7 to 0.9.11.

I made the corrections to call correctly the updated components.

BootActiveForm is displaying correctly but error handlers do not display.

Moreover, the BootMenu does not display sub-elements (when you have ‘items’).

Is there a config option I missed?

I’m running Yii 1.1.8

Many thanks

hi Chris :

i use the bootstrap gii to generate the crud views , found that you didn’t upgrade it to the latest version .

Release 0.9.11 change : "Renamed BootButton::fn to buttonType" ,

in the _form.php template view the fn still be there :lol:

Hi guys…

I’m not sure if I worked for nothing but the first thing I have done to start playing with this extension is mounting a “classic_bootstrap” theme to help me starting with bootstrap configured for the basic pages

If anyone is interested I can publish that

See ya…

Hwangar

Hi,

Can anyone give some working example on using BootModal which contains BootActiveForm and how to submit the form to the controller?

my idea is to get create, view and update of the gridview displayed in BootModal.

Cheers,

Daniel

Hi there

@Denis Roussel

Try to upgrade your yii framework. You will need jquery 1.7.1 which was upgraded in release 1.1.9.

Regards

On your admin view ‘admin’:

  1. strip out the default crud generated search form and other related like links and jquery script.

  2. put this code into your view




<?php

<?php $this->widget('bootstrap.widgets.BootButtonGroup', array(

    'buttons'=>array(

        array('label'=>'Advanced Search', 'url'=>'#modal', 'htmlOptions'=>array('data-toggle'=>'modal')),

    ),

));


$this->beginWidget('bootstrap.widgets.BootModal', array(

	'id'=>'modal',

	'htmlOptions'=>array('class'=>'hide'),

));


$this->renderPartial('_search',array('model'=>$model));


$this->endWidget();

?>



  1. on search view ‘_search’ fix up the generated code:



<?php $form=$this->beginWidget('bootstrap.widgets.BootActiveForm',array(

	'action'=>Yii::app()->createUrl($this->route),

	'method'=>'get',

)); ?>


	<div class="modal-header">

		<a class="close" data-dismiss="modal">&times;</a>

		<h3><?php echo Yii::t('interface', 'Advanced Search'); ?></h3>

	</div>


	<div class="modal-body">


	<?php echo $form->textFieldRow($model,'id',array('class'=>'span5')); ?>


        ...


	</div>

	

	<div class="modal-footer">

		<?php $this->widget('bootstrap.widgets.BootButtonGroup', array(

			 'buttons'=>array(

				  array('label'=>Yii::t('interface', 'Search'), 'url'=>'#', 'type'=>'submit', 'htmlOptions'=>array('submit'=>'', 'class'=>'btn-primary')),

				  array('label'=>Yii::t('interface', 'Close'), 'url'=>'#', 'htmlOptions'=>array('data-dismiss'=>'modal')),

			 ),

		)); ?>	

	</div>


<?php $this->endWidget(); ?>



Now to do the others views you should create ajaxLinks and the correct jquery function to update the modal content. If you want your modal bigger just create another css class with:

[css]

.big-modal {

width:96%;

margin-left: -48%;

max-height: 900px;

}

[/css]

of course you can change this to whatever u want.

I tried to do the exactly the same thing you are trying to achieve but modal mix up some other stuff so i’m just using to show the advanced search.

If you need more help add me on msn/gtalk (thiagovidal@gmail.com) or skype(thiago2vidal)

Cheers

I just got the update 2, i didn’t got errors. just the caret on gridview. Could you be more specific?

@thiagovidal:

Thanks for the example. The example is for the GET method, is it also working on the POST? Do I need different BootModal for each action, say 3 BootModal for create and update (share the same _form), _view (BootDetailView), _search?

Cheers,

Daniel

Dude, I think the post request will do exactly the same thing. I tried to use BootModal to open views but the yii list-view ajax stop working after modal close. I removed the modal via console and the yii list-view started work again.

When I did the test above, I create another action like actionViewAjax($id)… $this->renderPartial(‘view’, array(‘model’=>$model)); and create a CHtml::ajaxLink to refresh the content of modal. I used just one modal for everything.

I think I’ve found a bug in BootMenu.php (89):




//echo '<li class="divider-vertical"></li>';

echo '<li class="divider"></li>';



Should be just divider for BootMenu type=list??? Otherwise separator won’t appear…

Thx!

Hwangar

Yes. Other widgets are working fine. (menu, buttons, etc).

Hi Chris, is there a good way to set a selected tab & it’s content active when you have multiple tabs. At the moment I am using $_GET (as per suggested)and Jquery to remove active class and set the desire tab to active, but I couldn’t help but ask, there is got to be a better way.




    $('.nav-tabs').find('li').removeClass('active');

    $('a[href$=#'+t+']').parent().addClass('active');

    $('#'+t).addClass('active');




where t is stores the tab interested.

And how do you get the ID of the tab e.g. "yw1_tab_2", as the "yw1" part would change.

Whenever I try to create a form with the type property I am getting the following error.

Property "CActiveForm.type" is not defined.

My code for creating the form is as follows.

$form = $this->beginWidget(‘CActiveForm’, array(

    'id' =&gt; 'the-form',


    'type'=&gt;'inline',


    'enableAjaxValidation' =&gt; false,


    'htmlOptions' =&gt; array('enctype' =&gt; 'multipart/form-data'),


        ));

Any ideas as to why this is happening? (note: if I comment out type a form the code runs, just in the default form format)

Thanks

Also noticed a similar area is happening in grid view.

Hello,

is it possible to set ‘items’ from bootstrap.widgets.BootMenu dynamic? For example with values from a database? What would one approach look like? Well, due I’m quite new to frameworks, especially to yii, I don’t know where to start. I don’t expect a ready solution, more an approach, which would make it possible that I could work with. Thanks in advance - stepPwnInf

Hello,

Is possible open automatically BootModal?

Thanks.

Sergio

I googled around, and have read some articles. Here is my approach:


main view


$navHeaders=NavigationItem::model()->with('navigationHeader')->findAll();

       

        $items = array();

        foreach ($navHeaders as $key)

        {

          $items[] = array(array('label' => $key->navigationHeader->content),

              array('label' => $key->content, 'url'=>'#'));

        }

          $this->widget('bootstrap.widgets.BootMenu', array(

            'type'=>'list',

            'items'=>$items ));

        

The Navlist still is empty, but when I make use of print_r($items), I can verify that the array isn’t empty. What is the next step?

Tooltips in BootButtonColumn doesn’t working after updating grid with ajax (for example changing page). Any ideas how to fix this ?

In a thread about getting database value into CMenu, someone recommended to subclass from CMenu. To my specific problem that means, I subclass from BootMenu and reimplement the init() function. Here is the code:


public function init()

  {

    

        $items=CmsNavigationItem::model()->with('navigationHeader')->findAll();     

        foreach ($items as $key)

        {

         $this->items[] = array(array('label' => $key->navigationHeader->content),array('label'=>$key->content, 'url'=>'#'));

        }


        parent::init();

  }

The code in views/layouts/main:


$this->widget('application.components.MenuItems', array( 

        'type'=>'list'));

I want one Header as seperator between the items, means the header is the category. The Items are related to one Header. So I need to get two different items, that I can pass dynamic. But with my approach nothing is listed anyway. What can I improve?

Custom labels for form input fields?

In some cases I need to display an attribute label that is different from the label set in the model class; e.g. "email address" instead of "email". Using labelEx() this is easy to do:




<?php echo $form->labelEx($model, 'email', array('label'=>'email address')); ?>

How does this work when using Yii-Bootstrap?

I tried to set an alternative “label” as parameter in “htmlOptions” array with no result because in BootInputHorizontal.php and BootInput.php (for vertical forms) all “htmlOptions” are being ignored in getLabel() function. In fact I don’t really understand the


protected function getLabel($htmlOptions = array())

because you never really seem to call this function with any additional “htmlOptions” thus the if condition to check for “class” is pointless somehow. Maybe you haven’t finished the function yet? To solve this on my side I’ve added the following…




protected function getLabel($htmlOptions = array())

{

	[...]


	if (isset($this->htmlOptions['label']))

		$htmlOptions['label'] = $this->htmlOptions['label'];


	[...]

Not sure if this is the proper thing to do but it works for me.

Maybe you intended to do the same thing for "class" but than I would call it "classForLabel" or so.

Any comment would be nice.