Hey Sergio, just put some jquery.
$(document).ready(function() {
$(’#modal-id’).modal(‘show’);
});
Hey Sergio, just put some jquery.
$(document).ready(function() {
$(’#modal-id’).modal(‘show’);
});
Dude, are u using a model? If yes why not set label parameters on model class?
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id'=>Yii::t('users', 'ID'),
'username'=>Yii::t('users', 'Username'),
'password'=>Yii::t('users', 'Password'),
'email'=>Yii::t('users', 'Email address'),
);
}
It works! Thanks!
update
ps: buttons, menu and other widgets are working fine.
Of course, I do and I mentioned this at the beginning of my post, see above. In some situations I need to display another label than the one set in model class. Yii already offers this option in labelEx() function - set alternative label as parameter in "htmlOptions" array.
It would be quite nice to add this option to Yii-Bootstrap, too?
I’ve offered a solution/sample code and believe this is the right way to do this.
How about adding an optional "autoOpen" parameter (like in CJuiDialog)?
<?php $this->beginWidget('bootstrap.widgets.BootModal', array(
'id' => 'loginmodal',
'options'=>array('autoOpen' => $model->hasErrors()?true:false)
)); ?>
In BootModal.php you need to add the following:
public function run()
{
[...]
if ($this->options['autoOpen'] === true)
{
Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.show',
"jQuery('#{$this->id}').modal('show');");
}
}
Just an idea… so you don’t need to add any extra jQuery code manually.
The BootMenu.php by default does not normalize URL’s. This can be easily fixed by adding these lines in ‘normalizeItems()’:
if (isset($item['url']) && is_array($item['url']))
$item['url'] = CHtml::normalizeUrl($item['url']);
This also changes the menu ‘url’ option to an array, just like CMenu. But it doesn’t break the previous URL system.
Hi,
Thank you for the great extension.
I was trying to use BootAlert, all was ok except the close button, it didn’t work.
So I went to take a look at BootAlert.php and found a commented code that I think is to close the alert:
/*
// Register the "close" event-handler.
if (isset($this->events['close']))
{
$fn = CJavaScript::encode($this->events['close']);
Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.close', "jQuery('{$selector}').bind('close', {$fn});");
}
// Register the "closed" event-handler.
if (isset($this->events['closed']))
{
$fn = CJavaScript::encode($this->events['closed']);
Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.closed', "jQuery('{$selector}').bind('closed', {$fn});");
}
*/
Why is it commented?
Thanks.
I finally found what was wrong with button-group, where the dropdown arrow had way to low height.
I changed css class .dropdown-toggle and added height:18px; to it. It’s in bootstrap.min.css
It’s commented out because the fix didn’t make it for the 0.9.11 release. However, this has been fixed in the development branch and will be included in the next release.
Hi,
Is BootActiveForm working ok with ‘enableClientValidation’=>true and ‘validateOnSubmit’=>true?
I have this not working:
<?php $form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'login-form',
'enableClientValidation'=>true,
'clientOptions' => array(
'validateOnSubmit' => true,
),
'type'=>'horizontal',
)); ?>
<fieldset>
<legend>Login</legend>
<p><?php echo Yii::t('site', 'Fields with {extra} are required.', array('{extra}' => '<span class="required">*</span>')); ?></p>
<?php $this->widget('bootstrap.widgets.BootAlert'); ?>
<?php echo $form->textFieldRow($model, 'username'); ?>
<?php echo $form->passwordFieldRow($model, 'password'); ?>
</fieldset>
<div class="form-actions">
<?php $this->widget('bootstrap.widgets.BootButton', array('buttonType'=>'submit', 'type'=>'primary', 'icon'=>'ok white', 'label'=>'Login')); ?>
</div>
<?php $this->endWidget(); ?>
The generated javascript at the end is:
/*<![CDATA[*/
jQuery(function($) {
jQuery('a[rel="tooltip"]').tooltip();
jQuery('a[rel="popover"]').popover();
jQuery('#yw0 .alert').alert();
$('#login-form').yiiactiveform({'validateOnSubmit':true,'attributes':[{'id':'LoginForm_username','inputID':'LoginForm_username','errorID':'LoginForm_username_em_','model':'LoginForm','name':'LoginForm[username]','enableAjaxValidation':false,'inputContainer':'div.control-group','clientValidation':function(value, messages, attribute) {
if($.trim(value)=='') {
messages.push("Username is required.");
}
}},{'id':'LoginForm_password','inputID':'LoginForm_password','errorID':'LoginForm_password_em_','model':'LoginForm','name':'LoginForm[password]','enableAjaxValidation':false,'inputContainer':'div.control-group','clientValidation':function(value, messages, attribute) {
if($.trim(value)=='') {
messages.push("Password is required.");
}
}}]});
});
/*]]>*/
If I submit the form with both fields empty the form is sent to the server, but it shouldn’t.
Thanks for the help.
Any advice on how I can easily include bootrstrap without ruining all my own CSS? It has some nice stuff, but there is some CSS that I really do not need…
Just apply the css classes u want to use and skip the rest…
Maybe make some adjustment for name colliding but thats it.
Its very easy to apply only bootstrap buttons for example.
Hi,
For me dropdowns and split dropdowns aren’t working, when I click on them it doesn’t show the menu.
Dropdowns:
<div class="btn-toolbar">
<?php $this->widget('bootstrap.widgets.BootButtonGroup', array(
'type'=>'primary', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons'=>array(
array('label'=>'Action', 'items'=>array(
array('label'=>'Action', 'url'=>'#'),
array('label'=>'Another action', 'url'=>'#'),
array('label'=>'Something else', 'url'=>'#'),
'---',
array('label'=>'Separate link', 'url'=>'#'),
)),
),
)); ?>
</div>
Split dropdowns:
<div class="btn-toolbar">
<?php $this->widget('bootstrap.widgets.BootButtonGroup', array(
'type'=>'primary', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons'=>array(
array('label'=>'Action', 'url'=>'#'),
array('items'=>array(
array('label'=>'Action', 'url'=>'#'),
array('label'=>'Another action', 'url'=>'#'),
array('label'=>'Something else', 'url'=>'#'),
'---',
array('label'=>'Separate link', 'url'=>'#'),
)),
),
)); ?>
</div>
Thanks for all the help.
Hi NCS_One,
the code (from the demo page) definitely works. Which bootstrap and jquery versions do you use? And make sure "bootstrap-dropdown.js" is included properly (check your source code; at the bottom). Having said this, if you have updated bootstrap recently, you should flush your "assets" folder.
Last not least, try using firebug and check for any error messages in console output?
On my side everything’s working fine with the dropdown but the “caret” side of the split dropdown is not rendered properly in Firefox 10.x and Safari on MacOS - see screenshot below. I’ve fixed this adding extra padding-bottom in my custom stylesheet as follows:
.btn .caret {
padding-bottom: 7px;
}
.btn-large .caret {
padding-bottom: 8px;
}
.btn-small .caret {
padding-bottom: 6px;
}
.btn-mini .caret {
padding-bottom: 5px;
}
How about IE, Chrome, Opera?
Hi,
Don Felipe thanks for your help.
On error console I’m getting the following error:
$("html").on is not a function
This on bootstrap-dropdown.js, the following line:
$('html').on('click.dropdown.data-api', clearMenus)
What should I do?
Update:
I was using yii-1.1.8.r3324, I updated to yii-1.1.10.r3566 and it works ok now.
My first guess is your jQuery version is too old for the bootstrap version you’re using - the latest bootstrap needs jQuery 1.7.1 or so. So what should you do?
Ideally you need to upgrade the Yii framework. Make a backup copy first!
Alternatively, you could replace the jQuery lib only and check if it solves the problem with your dropdowns and then upgrade the whole thing to the latest Yii framework that comes with (one of) the latest jQuery (versions).
jquery.js + jquery.min.js can be found in /path_to_yii_framework/web/js/source/.
After upgrading, and before testing, you need to flush the assets folder of your webapp.
Good luck,
df
Hello Everyone.
Hello Everyone, i just tried the bootstrap extension in yii, but i can’t find good documentation on how to define and tweak the widgets,
e.g.: i would like to tweak the speed, order etc options of the BootCarousel widget.
Anyone got any leads of any documentation ?
cheers
Not sure about a yii-way to configure the carousel, but you can use javascript to do that.
$cs->registerScript(
'bootCarouselRotator',
'$(\'.carousel\').carousel({
interval: 4500
});',
CClientScript::POS_END
);
// create an array with the wanted images(php 5.4):
$images[] = ['image'=>'http://placehold.it/1300x300&text=Insert+first+banner+here', 'label'=>'Some catchy label', 'caption'=>'Description and <a href="http://google.de">Link</a> to the file'];
$images[] = ['image'=>'http://placehold.it/1300x300&text=Insert+second+banner+here', 'label'=>'Some catchy label', 'caption'=>'Description and <a href="http://google.de">Link</a> to the file'];
// "order" them:
$images = array_reverse($images);
$this->render('index', ['addons' => $addons, 'images' => $images]);
Bootstrap documentation on that:
http://twitter.github.com/bootstrap/javascript.html#carousel
Thanks man, i was going through the bootstrap documentation and indeed they are well elaborated,
Then i was looking the the widget source code and looks like the options are the same, it just requires a bit of time and attention to get it right.
For some funny reason though my carousel it isn’t sliding smoothly.
For those who are new to bootstrap and this extension, a good start would be the bootstart documentation and than the yii php code.
enjoy