[EXTENSION] Bootstrap

Hello guys!

Anyone can help me?

Error: Alias "ext.bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing PHP file and the file is readable.

I unzip the extension in the directory: \protected\extensions\bootstrap

Main.php:

Thanks!

Diego Rodrigo

Quick question.I am using the TbGridView exactly as described in the demo and everything is fine.

However I cannot figure out how to display more than 10 records, and to display some navigation buttons to go to the next X(10) records.

I suspect this might be related to my limited knowledge on YII, but it looks trivial so I hope someone will be kind enough to help a newbie.Thanks.

Hi. Thank you for extension.

I have TbButtonColumn in TbGridView.

Is it possible to use popover behavior with buttons in this column?

I have try different ways


<?php

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

    'type'=>'striped bordered condensed',

    'dataProvider'=>$userHistory,

    'template'=>"{items}",

    'columns'=>array(

        array('header'=>'#', 'name'=>'id'),

...

        //1st way

        array(

            'header'=>'Test',

            'type'=>'html',

            'value'=>"$this->widget(

                'bootstrap.widgets.TbButton', 

                array(

                    'label'=>'Click me',

                    'type'=>'danger',

                    'htmlOptions'=>array(

                        'data-title'=>'A Title', 

                        'data-content'=>'And here\'s some amazing content. It\'s very engaging. right?',

                        'rel'=>'popover'

                    ),

                )

            )"

        ),

        //2nd way

        array(

            'header'=>'Actions',

            'class'=>'bootstrap.widgets.TbButtonColumn',

            'htmlOptions'=>array('style'=>'width: 50px; text-align: center;'),

            'template'=>'{info}',

            'buttons'=>array(

                'info' => array(

                    'label'=>'Info',

                    'icon'=>'info-sign',

                    'url'=>'"#"',

                    'htmlOptions'=>array('data-title'=>'A Title', 'data-content'=>'And here\'s some amazing content. It\'s very engaging. right?', 'rel'=>'popover'),

                ),

            ),

        ),

    )

));

1st way gives me "Property "SomeController.widget" is not defined."

2nd doesn’t give me any result. Botton steal have tooltip behavior :(

How do you bind a TbTypeahead to a model? I’ve tried the following, but it does not work.




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

  'model' => Department::model(),

  'attribute' => 'department_name',

  'options'=>array(

    'items'=>4,

    'matcher'=>"js:function(item) {

      return ~item.toLowerCase().indexOf(this.query.toLowerCase());

    }",

  ),

)); ?>



Hello!

Have you had problems with render error messages when the forms are validated by AJAX?

How to solve?

Hi!

I may repeat, but I have a problem. The fact is that when I use the Cyrillic cp1251 in yii-bootstrap (whether in the menus, buttons), the words disappear. I set utf-8 encoding. In other words, it does not work in Cyrillic UTF-8.

Thanks in advance!

Hey,you were right,i only have BootNavbar.php,is it the old version or the newest?,because i used the one i `ve found at www{dot}cniska{dot}net{slash}yii-bootstrap thanks a lot,its good to belong to community!

Please use one of the downloads on the right hand side of this link.

yii-bootstrap-1.x => widgets.Tb… (new)

yii-bootstrap-0.9.x => widgets.Boot… (old)

The 1.x versions are not backward compatible! As of now there is no reason to use the older version when starting a new project, so please use 1.1. If you update a existing webapp from 0.9 to 1.x simply search and replace all .php files under /protected and replace "bootstrap.widgets.Boot" with "bootstrap.widgets.Tb".

For some reason unknown to me, the errors returned by performAjaxValidation are not listed on the forms that use ajaxSubmit the end of the request.

To solve this, I created the following function:




function showAjaxValidationMessages(response) {

    for (idInput in response) {

	while(response[idInput]) {

	    $('#' + idInput + '_em_').empty().html(response[idInput][0]).fadeIn('low');

	    break;

	}

    }

}



In ajaxOptions:




'ajaxOptions' => array(

    'dataType' => 'json',

    'success' => "function(response) {

	showAjaxValidationMessages(response);

    }",

),



i set Yii::app()->charset=‘cp1251’; in view, but its not worked when i set charset value in config

Hello,@Don Felipe,thx for greats tips,you really saved me here,i am actually having some issue with url routing while using TbMenu widget,i am using the format of /moduleId/ControllerId/ActionId in accessing module Controllers,here is an example


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

    'type'=>'inverse', // null or 'inverse'

    'brand'=>'CODEPAC',

    'brandUrl'=>'#',

    'collapse'=>true, // requires bootstrap-responsive.css

    'items'=>array(

        array(

            'class'=>'bootstrap.widgets.TbMenu',

            'items'=>array(

                array('label'=>'Home','url'=>array('/site/index'), 'active'=>true),

                array('label'=>'About', 'url'=>array('/site/page')),

                array('label'=>'Contact us','url'=>array('/site/contact')),

            ),

        ),

        '<form class="navbar-search pull-left" action=""><input type="text" class="search-query span2" placeholder="Search"></form>',

        array(

            'class'=>'bootstrap.widgets.TbMenu',

            'htmlOptions'=>array('class'=>'pull-right'),

            'items'=>array(

                array('label'=>'Sign in', 'url'=>'/user/auth','visible'=>Yii::app()->user->isGuest),

                '---',

               [b] array('label'=>'Profile', 'url'=>'/user/user','visible'=>!Yii::app()->user->isGuest, 'items'=>array([/b]

                    [b]array('label'=>'Settings', 'url'=>'user/user/index'),[/b]

                    [b]array('label'=>'Logout', 'url'=>'user/user/logout')[/b],


                )),

            ),

        ),

    ),



the three last line are the ones that are causing problem,when i try to access those links after clicking on home,page,contact us(using the Site controller actions that are auto-generated by the Yii) the route is appended to the existing url in stead of creating a new url to the module,for example if am on home page(after clicking home it has this as url http:localhost/mysite/index.php/site/index)it gives me this url http://localhost/mysite/index.php/site/index/user/user/index,if i go the same link again with this as url it gives me http://localhost/mysite/index.php/site/index/user/user/index/user/user/index if i click again it add another one again and again…but the strange in all is that it works fine with CMenu,here is snippet of CMenu that works fine,


<?php $this->widget('zii.widgets.CMenu',array(

                        'items'=>array(

                                array('label'=>'Home', 'url'=>array('/site/index')),

                                array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),

                                array('label'=>'Contact', 'url'=>array('/site/contact')),

                                array('label'=>'Login', 'url'=>array('//user/auth'), 'visible'=>Yii::app()->user->isGuest),

                                array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('//user/user/logout'), 'visible'=>!Yii::app()->user->isGuest),

                                array('label'=>'My profile ', 'url'=>array('/user/user/'), 'visible'=>!Yii::app()->user->isGuest),

                        ),

                )); ?>




i am assuming that it might be caused by the fact that those links are submenu but i am not sure since the first in those links is not submenu and has the same problem!thank you again

@spiderboy7:

uhm, there’s a huge difference between:




'url'=>array('/site/faq')

'url'=>array('site/faq')

'url'=>'/site/faq'

'url'=>'site/faq'



the first 2 will look for a controller route -defined as rules of the urlManager in main config.php- and return an absolute link. you can also easily append additional ids (url parameter) this way.

the latter 2 will treat ‘url’ as a simple string, and the value will be returned without any change.

<a href="/site/faq">

<a href="site/faq">

it should be obvious by now why some of your links don’t work. the leading ‘/’ is missing. when you’re in ‘/site/faq’ and click on ‘site/faq’ the browser will request ‘/site/site/faq’ and so on and on.

hope it helps. it’s already late here and i’m too tired for typing.

—edited/added next morning—

here’s some basic info about URL management in Yii:

CHtml::link

CHtml::normalizeUrl

CController::createUrl

and

URL Management

have a nice day!

hey @Don Felipe…thanks again for your tips…i needed the first actually since i needed a route to the module and controller,thanks again…it worked fine!i have to read a bit about url Managment thought!

Hello guys!

Anyone can help me?

Error: Alias "ext.bootstrap.components.Bootstrap" is invalid. Make sure it points to an existing PHP file and the file is readable.

I unzip the extension in the directory: \protected\extensions\bootstrap




Main.php:


<?php


return array(

'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

'name'=>'Supplier Quality Management',


'preload'=>array(

'log',

'bootstrap',

),


'import'=>array(

'application.models.*',

'application.components.*',

),


'modules'=>array(

'gii'=>array(

'generatorPaths'=>array(

'bootstrap.gii',

),

),

),


'components'=>array(

'bootstrap'=>array(

'class'=>'ext.bootstrap.components.Bootstrap',

),


'user'=>array(

'allowAutoLogin'=>false,

'loginUrl'=>array('site/login'),

),


'db'=>array(

'connectionString' => 'mysql:host=localhost;dbname=sqm',

'emulatePrepare' => true,

'username' => 'root',

'password' => '',

'charset' => 'utf8',

),


'errorHandler'=>array(

'errorAction'=>'site/error',

),

'log'=>array(

'class'=>'CLogRouter',

'routes'=>array(

array(

'class'=>'CFileLogRoute',

'levels'=>'error, warning',

),

),

),

),


'params'=>array(

'adminEmail'=>'webmaster@example.com',

),

);



Thanks!

Diego Rodrigo

hello Diego,i think your configuration is fine,maybe you should check if you are not using the old version of Yii-bootrap,here is the link to the new oneget the newest version

i’m very stupid!!!

i had done the download on bootstrap site, not the yii extension, now it’s working!

Thanks a lot!!

Is the Bootstrap-Wysihtml5 plugin included (http://jhollingworth.github.com/bootstrap-wysihtml5/)? If so, is there a usage example somewhere?

Is there a way to append a button to an input, as demonstrated in the Bootstrap documentation? The closest I have got is to assign the button code to the htmlOptions append property:




<?php

    $this->beginClip('searchBtn');

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

        'icon'=>'icon-search',

        'type'=>'info',

        'url'=>'#lookupModal',

        'htmlOptions'=>array(

            'rel'=>'popover', 

            'data-toggle'=>'modal')

        ));

    $this->endClip();

?>

<?php echo $form->textFieldRow($model, 'memberName',

    array(

        'class'=>'span5',

        'readonly'=>true,

        'append'=>$this->clips['searchBtn'],

    ));

?>



All this does is to render the button in a text add-on area. What I want is for the button to be appended directly to the input.

Can anybody help me with this?

Thanks!

Timbo, your approach is too complicated. Just render the 2 elements as usual and put a div around it.

Something like this… (untested but should work)


<div class="input-append">

  <?php echo $form->textFieldRow($model, 'attribute', array('class'=>'input-medium')); ?>

  <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'button', 'label'=>'Go')); ?>

</div>

If you need another input or button just put another widget inside the parent div. If you want to get rid of the annoying label of the input (yes you do); the answer can be found in a previous post above and not so long ago.

Cheers,

DF

Thanks DF. Believe me I have tried the simpler approaches, including the one you gave. The problem is that textFieldRow writes the error message stuff after the input, so the button is appended after that. This leaves a space between the input box and the button. I have got it to work correctly on an uneditableRow, like this:


<div class="input-append">          

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

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

        'icon'=>'icon-search',

        'type'=>'info',

        'url'=>'#lookupModal',

        'htmlOptions'=>array(

            'rel'=>'popover', 

            'data-toggle'=>'modal'),

        )); ?>

</div>           	



But I really need it to work with text inputs.