[EXTENSION] Bootstrap

  1. Many ways to accomplish this. To omit the "X" for all alerts add this to your stylesheet:

.alert-block a.close {

    display:none;

}

If you want to omit the "X" for a certain alert only while still visible for all the other alerts, add a class…


<?php 		

    user()->setFlash('info', 'your alert message');

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

        'htmlOptions'=>array('class'=>'alertWithoutX')

    ));

?>

…and replace the ".alert-block" with the new classname:


.alertWithoutX a.close {

    display:none;

}

  1. Like adding one of the bootstrap-icons to the alert message? (remove the "icon-white" for black icon)

<?php 		

    user()->setFlash('info', '<i class="icon-info-sign icon-white"></i> alert with a fancy icon!');

    [...]

?>

BootNavbar: Simply add this to your stylesheet:


.navbar-inner {

    background-color: #424242;

    background-image: none; 

}

Hi,

Am I doing something wrong or when a model with errors is rendered the validation errors are showed but not in red (this because the error class is not added)?

Ok found the problem.

To find if attribute has errors you don’t use the input name but the attribute name.

On BootInput.php line 262, change this:


if ($this->model->hasErrors(CHtml::resolveName($this->model, $this->attribute)))

to:


if ($this->model->hasErrors($this->attribute))

Hello I’m new…

i want to add html attribute at bootstrap.widgets.BootMenu

<a href="#">

<i class="icon-cog"></i>

Create New

</a>

to be

<a href="#" id="click">

<i class="icon-cog"></i>

Create New

</a>

can anyone help me?

because google just give me this forum at first page when i search "How to add html attribute on bootstrap.widgets.BootMenu"

Sorry if my question very newbie :)

Thanks

Hi,

Look at last item:




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

    'type'=>'list',

    'items'=>array(

        array('label'=>'LIST HEADER', ),

        array('label'=>'Home', 'icon'=>'home', 'url'=>'#', 'active'=>true),

        array('label'=>'Library', 'icon'=>'book', 'url'=>'#'),

        array('label'=>'Application', 'icon'=>'pencil', 'url'=>'#'),

        array('label'=>'ANOTHER LIST HEADER'),

        array('label'=>'Profile', 'icon'=>'user', 'url'=>'#'),

        array('label'=>'Settings', 'icon'=>'cog', 'url'=>'#'),

        array('label'=>'Help', 'icon'=>'flag', 'url'=>'#', 'linkOptions'=>array('id'=>'click')),

    ),

)); ?>



Tq tq… it’s work…

btw where i can get the documentation of any option for modified bootstrap extension. hmm any simple modification like my question actually :)

I look at the source code :)

Hello…

how to change background color for nav bar?

I try to override class navbar inner, but it is still not worked :(

I want to change to #443266, can i still get gradient color?

This is the original class in bootstrap.css:


.navbar-inner {

  padding-left: 20px;

  padding-right: 20px;

  background-color: #2c2c2c;

  background-image: -moz-linear-gradient(top, #333333, #222222);

  background-image: -ms-linear-gradient(top, #333333, #222222);

  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222));

  background-image: -webkit-linear-gradient(top, #333333, #222222);

  background-image: -o-linear-gradient(top, #333333, #222222);

  background-image: linear-gradient(top, #333333, #222222);

  background-repeat: repeat-x;

  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);

  -webkit-border-radius: 4px;

  -moz-border-radius: 4px;

  border-radius: 4px;

  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);

  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);

  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);

}

You need to change and overwrite

  • background-color,

  • background-image, and

  • filter (for IE).

No gradient:


.navbar-inner {

  background-color: #443266;

  background-image: none;

  filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);

}



or to be super careful:


.navbar-inner {

  background-color: #443266;

  background-image: -moz-linear-gradient(top, #443266, #443266);

  background-image: -ms-linear-gradient(top, #443266, #443266);

  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#443266), to(#443266));

  background-image: -webkit-linear-gradient(top, #443266, #443266);

  background-image: -o-linear-gradient(top, #443266, #443266);

  background-image: linear-gradient(top, #443266, #443266);

  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#443266', endColorstr='#443266', GradientType=0);

}

With gradient effect using your color:


.navbar-inner {

  background-color: #443266;

  background-image: -moz-linear-gradient(top, #443266, #663288);

  background-image: -ms-linear-gradient(top, #443266, #663288);

  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#443266), to(#663288));

  background-image: -webkit-linear-gradient(top, #443266, #663288);

  background-image: -o-linear-gradient(top, #443266, #663288);

  background-image: linear-gradient(top, #443266, #663288);

  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#443266', endColorstr='#663288', GradientType=0);

}

Tq2 i overide with your css and it’s work. because the yii css was minified i can’t see that all css. Thanks Felipe

Hello Again, I’m sorry if i have too many question

how to get data from database for




<?php echo $form->dropDownListRow($model, 'dropdown', array('Something ...', '1', '2', '3', '4', '5')); ?>



I always get error "Cannot Object to String"

Or just give me "0" result

then wrong argument for foreach…

Tq before

I recently achieved this by doing the following. In the appropriate action in your controller, fetch your data, and pass it into your render.




	$dataProvider=new CActiveDataProvider('RoomType');

		$roomTypes = $dataProvider->getData();

		

		$roomTypesDropdown = Array(); //Store it in a simple array.

		foreach($roomTypes as $roomType) {

			$roomTypesDropdown[$roomType->id] = $roomType->description;

		}

		$this->render('create',array(

			'model'=>$model,

			'roomTypes'=>$roomTypesDropdown,

		));






Then in your form




	<?php echo $form->dropDownListRow($model,'roomid',$roomTypes); ?>



Hope that helps.

Edit

Don Felipe’s answer below is far better.

… or …


<?php echo $form->dropDownListRow(

  $model,                       //1st: model

  'id',                         //2nd: attribute 

  CHtml::listData(              //3rd: data

    User::model()->findAll(),     // dataProvider

    'id',                         // attribute to be used as option value

    'username'                    // attribute to be displayed

  ), 

  array(                        //4th: additional htmlOptions

  )                      

); ?>

Of course you can use additional attributes and/or criteria to limit the user list with findAll().

Much nicer than the way I described. Thank you.

has anybody else had issues with the carousel not having transitions since the latest upgrade?

Hi,

Can someone please confirm if this is a extension issue.

On a horizontal form turning off javascript or setting enableAjaxValidation and enableClientValidation to false when a form is submited an attribute that is valid, has no errors, doesn’t became green because the class “success” is no added?

If it is a issue a quick fix could be changing in BootInput.php:




protected function getContainerCssClass()

{

  if ($this->model->hasErrors($this->attribute)) //I changed this before this issue, I posted why

    return CHtml::$errorCss;

  else

    if (Yii::app()->request->isPostRequest)

      return 'success';

    else

      return '';

}



Ok, soo if it has no errors and is a request of type POST I assume that it is a form submit and that the model has been validated and it is a valid attribute, so I add the class "success". If the attribute has no errors and the request is not of type POST no CSS class is added.

Some recommendations?

Also on CActiveRecord::onAfterVAlidate() could set some propertie indicating that the model validation has occurred and use it on BootInput::getContainerCssClass().

Hi,

thanks for the awesome extension!

I’m not a very experienced web developer so I might be missing something trivial, but once I had bootstrap preloaded, all my other jquery based extensions (fancybox, fbgallery etc) became pretty messed up. For example fancybox does not popup because the script crashes when calling hide() on a div, fbgallery has similar issues with jquery ui dialogs. Is there a conflict between bootstrap based and traditional jquery/jquery ui/CJui based widgets? Or is there some version incompatibility?

I’m using Yii 1.1.8.

Any hint or advice is greatly appreciated!

Thanks!

any of you getting problems with the Bootstrap generator ?

I check at the controller

did the Bootstrap CRUD doing validation ?


		

if(isset($_POST['Post']))

{

        $model->attributes=$_POST['Post'];

	if([b]$model->save()[/b])

	$this->redirect(array('view','id'=>$model->id));

}

one more thing is, when I tried to create something,

based on the rules that I state as required

when I leave all the form blank, it just redirect me to view.

Hi,

How do you default check a radio button list?




<?php echo $form->radioButtonListInlineRow($model, 'main', array(true=>'Yes', false=>'No')); ?>



The $model->main is false but the radio false/No is not checked.

Ok, found the problem.

$model->main is of type boolean, I have to change true to 1 and false to 0.