All the YiiBootstrap widgets...
You use boxes to wrap up elements with a nice window effect. Boxes is a CPorlet type widget with the beauty of Bootstrap
$this->widget('bootstrap.widgets.TbBox', array(
'title' => 'Basic Box',
'headerIcon' => 'icon-home',
'content' => 'My Basic Content (you can use renderPartial here too :))' // $this->renderPartial('_view')
));
We can also wrap up content differently.
<?php $box = $this->beginWidget('bootstrap.widgets.TbBox', array(
'title' => 'Advanced Box',
'headerIcon' => 'icon-th-list',
// when displaying a table, if we include bootstra-widget-table class
// the table will be 0-padding to the box
'htmlOptions' => array('class'=>'bootstrap-widget-table')
));?>
<table class="table">
<thead>
<tr>
<th>#</th>
<th>First name</th>
<th>Last name</th>
<th>Language</th>
<th>Hours worked</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td><td>Mark</td><td>Otto</td><td>CSS</td><td>10</td>
</tr>
<tr class="even">
<td>2</td><td>Jacob</td><td>Thornton</td><td>JavaScript</td><td>20</td>
</tr>
<tr class="odd">
<td>3</td><td>Stu</td><td>Dent</td><td>HTML</td><td>15</td>
</tr>
</tbody>
</table>
<?php $this->endWidget();?>
You can also set actions to a box, so they can nicely display on its right corner as a dropdown button -icon actions on the way :)
Heads Up! Now you can add any type of buttons to boxes
$this->widget('bootstrap.widgets.TbBox', array(
'title' => 'test',
'headerIcon' => 'icon-home',
'headerButtons' => array(
array(
'class' => 'bootstrap.widgets.TbButtonGroup',
'type' => 'primary', // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons' => array(
array('label' => 'Action', 'url' => '#'), // this makes it split :)
array('items' => array(
array('label' => 'Action', 'url' => '#'),
array('label' => 'Another action', 'url' => '#'),
array('label' => 'Something else', 'url' => '#'),
'---',
array('label' => 'Separate link', 'url' => '#'),
)),
)
),
array(
'class' => 'bootstrap.widgets.TbButtonGroup',
'buttons'=>array(
array('label'=>'Left', 'url'=>'#'),
array('label'=>'Middel', 'url'=>'#'),
array('label'=>'Right', 'url'=>'#')
),
),
)));
| Labels | Markup |
|---|---|
| Default |
<span class="label">Default</span>
|
| Success |
<span class="label label-success">Success</span>
|
| Warning |
<span class="label label-warning">Warning</span>
|
| Important |
<span class="label label-important">Important</span>
|
| Info |
<span class="label label-info">Info</span>
|
| Inverse |
<span class="label label-inverse">Inverse</span>
|
$this->widget('bootstrap.widgets.TbLabel', array(
'type'=>'success', // 'success', 'warning', 'important', 'info' or 'inverse'
'label'=>'Success',
));
| Name | Example | Markup |
|---|---|---|
| Default | 1 |
<span class="badge">1</span>
|
| Success | 2 |
<span class="badge badge-success">2</span>
|
| Warning | 4 |
<span class="badge badge-warning">4</span>
|
| Important | 6 |
<span class="badge badge-important">6</span>
|
| Info | 8 |
<span class="badge badge-info">8</span>
|
| Inverse | 10 |
<span class="badge badge-inverse">10</span>
|
$this->widget('bootstrap.widgets.TbBadge', array(
'type'=>'success', // 'success', 'warning', 'important', 'info' or 'inverse'
'label'=>'2',
));
A lightweight, flexible component to showcase key content on your site. It works well on marketing and content-heavy sites.
This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
<?php $this->beginWidget('bootstrap.widgets.TbHeroUnit', array(
'heading'=>'Hello, world!',
)); ?>
<p>This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<p>
<?php $this->widget('bootstrap.widgets.TbButton', array(
'type'=>'primary',
'size'=>'large',
'label'=>'Learn more',
)); ?>
</p>
<?php $this->endWidget(); ?>
Not part of any widget but worth to know: A simple shell for an h1 to appropriately space out and
segment sections of content on a page. It
can utilize the h1's default small, element as well most other components (with
additional styles).
<div class="page-header"> <h1>Example page header <small>Subtext for header</small></h1> </div>
By default, Bootstrap's thumbnails are designed to showcase linked images with minimal required markup.
$this->widget('bootstrap.widgets.TbThumbnails', array(
'dataProvider'=>$thumbDataProvider,
'template'=>"{items}\n{pager}",
'itemView'=>'_thumb',
));
Yii::app()->user->setFlash('success', '<strong>Well done!</strong> You successfully read this important alert message.');
$this->widget('bootstrap.widgets.TbAlert', array(
'block'=>true, // display a larger alert block?
'fade'=>true, // use transitions?
'closeText'=>'×', // close link text - if set to false, no close link is displayed
'alerts'=>array( // configurations per alert type
'success'=>array('block'=>true, 'fade'=>true, 'closeText'=>'×'), // success, info, warning, error or danger
),
));
Default progress bar with a vertical gradient.
$this->widget('bootstrap.widgets.TbProgress', array(
'type'=>'success', // 'info', 'success' or 'danger'
'percent'=>60,
));
Uses a gradient to create a striped effect. Not available in IE7-8.
$this->widget('bootstrap.widgets.TbProgress', array(
'type'=>'success', // 'info', 'success' or 'danger'
'percent'=>60,
'stripped'=>true
));
Set animated to true to animate the stripes right to left. Not available in
all versions of IE.
$this->widget('bootstrap.widgets.TbProgress', array(
'percent'=>40, // the progress
'striped'=>true,
'animated'=>true,
));
Place multiple bars into the same .progress to stack them.
$this->widget('bootstrap.widgets.TbProgress', array(
'stacked'=>array(
array('type'=>'success', 'percent'=>30, 'htmlOptions'=>array('title'=>'Hey! I am a title here.')),
array('type'=>'warning', 'percent'=>35),
array('type'=>'danger', 'percent'=>30),
)));
Progress bars use CSS3 gradients, transitions, and animations to achieve all their effects. These features are not supported in IE7-9 or older versions of Firefox.
Versions earlier than Internet Explorer 10 and Opera 12 do not support animations.
| First name | Mark |
|---|---|
| Last name | Otto |
| Language | CSS |
$this->widget('bootstrap.widgets.TbDetailView', array(
'data'=>array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'),
'attributes'=>array(
array('name'=>'firstName', 'label'=>'First name'),
array('name'=>'lastName', 'label'=>'Last name'),
array('name'=>'language', 'label'=>'Language'),
),
));
In order to test the Grid Views we make use of the following data:
// $gridDataProvider
$mark = new Person();
$mark->id = 1;
$mark->firstName = 'Mark';
$mark->lastName = 'Otto';
$mark->language = 'CSS';
$mark->hours = 10;
$jacob = new Person();
$jacob->id = 2;
$jacob->firstName = 'Jacob';
$jacob->lastName = 'Thornton';
$jacob->language = 'JavaScript';
$jacob->hours = 20;
$stu = new Person();
$stu->id = 3;
$stu->firstName = 'Stu';
$stu->lastName = 'Dent';
$stu->language = 'HTML';
$stu->hours = 10;
$persons = array($mark, $jacob, $stu);
$gridDataProvider = new CArrayDataProvider($persons);
// $gridColumns
$gridColumns = array(
array('name'=>'id', 'header'=>'#', 'htmlOptions'=>array('style'=>'width: 60px')),
array('name'=>'firstName', 'header'=>'First name'),
array('name'=>'lastName', 'header'=>'Last name'),
array('name'=>'language', 'header'=>'Language'),
array('name'=>'hours', 'header'=>'Hours worked'),
array(
'htmlOptions' => array('nowrap'=>'nowrap'),
'class'=>'bootstrap.widgets.TbButtonColumn',
'viewButtonUrl'=>null,
'updateButtonUrl'=>null,
'deleteButtonUrl'=>null,
)
);
$this->widget('bootstrap.widgets.TbGridView', array(
'dataProvider'=>$gridDataProvider,
'template'=>"{items}",
'columns'=>$gridColumns,
));
this->widget('bootstrap.widgets.TbGridView', array(
'type'=>'striped',
'dataProvider'=>$gridDataProvider,
'template'=>"{items}",
'columns'=>$gridColumns,
));
$this->widget('bootstrap.widgets.TbGridView', array(
'type'=>'bordered',
'dataProvider'=>$gridDataProvider,
'template'=>"{items}",
'columns'=>$gridColumns,
));
$this->widget('bootstrap.widgets.TbGridView', array(
'type'=>'condensed',
'dataProvider'=>$gridDataProvider,
'template'=>"{items}",
'columns'=>$gridColumns,
));
$this->widget('bootstrap.widgets.TbGridView', array(
'type'=>'striped bordered condensed',
'dataProvider'=>$gridDataProvider,
'template'=>"{items}",
'filter'=>$person->search(),
'columns'=>$gridColumns,
));
Use the well as a simple effect on an element to give it an inset effect.
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'verticalForm',
'htmlOptions'=>array('class'=>'well'),
)); ?>
<?php echo $form->textFieldRow($model, 'textField', array('class'=>'span3')); ?>
<?php echo $form->passwordFieldRow($model, 'password', array('class'=>'span3')); ?>
<?php echo $form->checkboxRow($model, 'checkbox'); ?>
<?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'label'=>'Login')); ?>
<?php $this->endWidget(); ?>
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'searchForm',
'type'=>'search',
'htmlOptions'=>array('class'=>'well'),
)); ?>
<?php
echo $form->textFieldRow($model, 'textField',
array('class'=>'input-medium', 'prepend'=>'<i class="icon-search"></i>'));
?>
<?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'label'=>'Go')); ?>
<?php $this->endWidget(); ?>
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'inlineForm',
'type'=>'inline',
'htmlOptions'=>array('class'=>'well'),
)); ?>
<?php echo $form->textFieldRow($model, 'textField', array('class'=>'input-small')); ?>
<?php echo $form->passwordFieldRow($model, 'password', array('class'=>'input-small')); ?>
<?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'label'=>'Log in')); ?>
<?php $this->endWidget(); ?>
<?php /** @var BootActiveForm $form */
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id'=>'horizontalForm',
'type'=>'horizontal',
)); ?>
<fieldset>
<legend>Legend</legend>
<?php echo $form->textFieldRow($model, 'textField',
array('hint'=>'In addition to freeform text, any HTML5 text-based input appears like so.')); ?>
<?php echo $form->datepickerRow($model, 'dateField',
array('hint'=>'Click inside! This is a super cool date field.',
'prepend'=>'<i class="icon-calendar"></i>')); ?>
<?php echo $form->dateRangeRow($model, 'dateRangeField',
array('hint'=>'Click inside! An even a date range field!.',
'prepend'=>'<i class="icon-calendar">>/i>',
'options' => array('callback'=>'js:function(start, end){console.log(start.toString("MMMM d, yyyy") + " - " + end.toString("MMMM d, yyyy"));}')
)); ?>
<?php echo $form->timepickerRow($model, 'timepicker', array('hint'=>'Nice bootstrap time picker', 'append'=>'<i class="icon-time" style="cursor:pointer"></i>'));?>
<?php echo $form->dropDownListRow($model, 'dropdown',
array('Something ...', '1', '2', '3', '4', '5')); ?>
<?php echo $form->dropDownListRow($model, 'multiDropdown',
array('1', '2', '3', '4', '5'), array('multiple'=>true)); ?>
<?php echo $form->select2Row($model, 'select2', array('asDropDownList' => false, 'options' => array(
'tags' => array('clever','is', 'better', 'clevertech'),
'placeholder' => 'type clever, or is, or just type!',
'width' => '40%',
'tokenSeparators' => array(',', ' ')
)));?>
<?php echo $form->fileFieldRow($model, 'fileField'); ?>
<?php echo $form->textAreaRow($model, 'textarea', array('class'=>'span8', 'rows'=>5)); ?>
<?php echo $form->redactorRow($model, 'redactor', array('class'=>'span4', 'rows'=>5)); ?>
<?php echo $form->html5EditorRow($model, 'wysihtml5', array('class'=>'span4', 'rows'=>5, 'height'=>'200', 'options'=>array('color'=>true))); ?>
<?php echo $form->ckEditorRow($model, 'ckeditor', array('options'=>array('fullpage'=>'js:true', 'width'=>'640', 'resize_maxWidth'=>'640','resize_minWidth'=>'320')));?>
<?php echo $form->markdownEditorRow($model, 'markdown', array('height'=>'200px'));?>
<?php echo $form->toggleButtonRow($model, 'toggle'); ?>
<?php echo $form->uneditableRow($model, 'uneditable'); ?>
<?php echo $form->textFieldRow($model, 'disabled', array('disabled'=>true)); ?>
<?php echo $form->textFieldRow($model, 'prepend', array('prepend'=>'@')); ?>
<?php echo $form->textFieldRow($model, 'append', array('append'=>'.00')); ?>
<?php echo $form->checkBoxRow($model, 'disabledCheckbox', array('disabled'=>true)); ?>
<?php echo $form->checkBoxListInlineRow($model, 'inlineCheckboxes', array('1', '2', '3')); ?>
<?php echo $form->checkBoxListRow($model, 'checkboxes', array(
'Option one is this and that—be sure to include why it\'s great',
'Option two can also be checked and included in form results',
'Option three can—yes, you guessed it—also be checked and included in form results',
), array('hint'=>'<strong>Note:</strong> Labels surround all the options for much larger click areas.')); ?>
<?php echo $form->radioButtonRow($model, 'radioButton'); ?>
<?php echo $form->radioButtonListRow($model, 'radioButtons', array(
'Option one is this and that—be sure to include why it\'s great',
'Option two can is something else and selecting it will deselect option one',
)); ?>
</fieldset>
<div class="form-actions">
<?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'type'=>'primary', 'label'=>'Submit')); ?>
<?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'reset', 'label'=>'Reset')); ?>
</div>
<?php $this->endWidget(); ?>
We have included the Select2 on roids plugin of Igor Vaynberg. The following is a simple example of the amount of possible features that this plugin can do. For further information on its use, please visit plugin docs.
$this->widget('bootstrap.widgets.TbSelect2', array(
'asDropDownList' => false,
'name' => 'clevertech',
'options' => array(
'tags' => array('clever','is', 'better', 'clevertech'),
'placeholder' => 'disciplines',
'width' => '40%',
'tokenSeparators' => array(',', ' ')
)));
The amazing work from Vitaliy Potapov, X-Editable, is also part of YiiBooster thanks to the generosity of its author.
Note: For a deeper understanding of the possibilities and configuration options of this widget, we highly recommend that you visit its demo page.
Important Note: If you still using the old JEditable widgets from previous versions of YiiBooster, please consider migrating to new TbEditable family of widgets as JEditable is not supported anymore.
Makes editable single attribute of model.
Note: Attribute should be safe (e.g. defined in rules() method of model).
It can be one of several types:
$this->widget('ext.editable.TbEditableField', array(
'type' => 'text',
'model' => $model,
'attribute' => 'textField',
'url' => $this->createUrl('site/editable'), //url for submit data
));
$this->widget('ext.editable.TbEditableField', array(
'type' => 'textarea',
'model' => $model,
'attribute' => 'textArea',
'url' => $this->createUrl('site/editable'), //url for submit data
'placement' => 'right',
));
$this->widget('ext.editable.TbEditableField', array(
'type' => 'select',
'model' => $model,
'attribute' => 'dropDown',
'url' => $this->createUrl('site/editable'), //url for submit data
'source' => array('Antonio', 'Ramirez', 'Cobos', 'Works', 'At', 'Clevertech'),
));
$this->widget('ext.editable.TbEditableField', array(
'type' => 'date',
'model' => $model,
'attribute' => 'dateField',
'url' => $this->createUrl('site/editable'), //url for submit data
'format' => 'dd-mm-yyyy',
'viewformat' => 'dd/mm/yyyy',
'placement' => 'right',
));
Makes editable several attributes of single model, shown as name-value table. Just define editable
section inside attribute config. Only safe attributes become editable.
For more information: please visit EditableDetailView
$this->widget('bootstrap.widgets.TbEditableDetailView', array(
'id' => 'region-details',
'data' => Region::model()->findByPk(1),
'url' => $this->createUrl('site/editable'), //common submit url for all editables
'attributes'=>array(
'country_code',
'name',
)
));
This is the EditableColumn widget from Vitaliy Potapov.
$this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'striped bordered',
'dataProvider' => new CActiveDataProvider('Region',array(
'criteria'=>array('condition'=>'id < 5'))
),
'template' => "{items}",
'columns' => array(
'country_code',
array(
'class' => 'bootstrap.widgets.TbEditableColumn',
'name' => 'name',
'sortable'=>false,
'editable' => array(
'url' => $this->createUrl('site/editable'),
'placement' => 'right',
'inputclass' => 'span3'
)
)),
));
Use the well as a simple effect on an element to give it an inset effect.
<div class="well"> ... </div>
Control padding and rounded corners with two optional modifier classes.
<div class="well well-large"> ... </div>
<div class="well well-small"> ... </div>
Use the generic close icon for dismissing content like modals and alerts.
<button class="close">×</button>
iOS devices require an href="#" for click events if you rather use an anchor.
<a class="close" href="#">×</a>
Simple, focused classes for small display or behavior tweaks.
Float an element left
class="pull-left"
.pull-left {
float: left;
}
Float an element right
class="pull-right"
.pull-right {
float: right;
}
Change an element's color to #999
class="muted"
.muted {
color: #999;
}
Clear the float on any element
class="clearfix"
.clearfix {
*zoom: 1;
&:before,
&:after {
display: table;
content: "";
}
&:after {
clear: both;
}
}
Create a wizard using the same settings and configuration as the Tabs component with minor additions to actually build a wizard.
$this->widget('bootstrap.widgets.TbWizard', array(
'type' => 'tabs', // 'tabs' or 'pills'
'tabs' => array(
array('label' => 'Home', 'content' => 'Home Content', 'active' => true),
array('label' => 'Profile', 'content' => 'Profile Content'),
array('label' => 'Messages', 'content' => 'Messages Content'),
),
));
As described above same configuration as the tabs widget apply to the wizard widget with the following additions:
| options | List of the wizard plugin JS options. See Wizard Github Page for a list of the available options |
| addTabsNavBar | Adds extra div with navbar classes to change the appearance of the tab navigation |
| pagerContent | The Next & Previous buttons displayed at the bottom of each tab content to move to the next and previous steps. |
Wizard has 8 different events that it fires when certain actions are performed. onInit,
onShow, onNext, onPrevious, onFirst, onLast,
onTabShow, onTabClick
Example usage with events callbacks
$this->widget('bootstrap.widgets.TbWizard', array(
'type' => 'tabs', // 'tabs' or 'pills'
'options' => array(
'onTabShow' => 'js:function(tab, navigation, index) { if((index+1) > 1) {alert("Tab #" + (index+1));} }',
'onTabClick' => 'js:function(tab, navigation, index) {alert("Tab Click Disabled");return false;}',
),
'tabs' => array(
array('label' => 'Home', 'content' => 'Home Content', 'active' => true),
array('label' => 'Profile', 'content' => 'Profile Content'),
array('label' => 'Messages', 'content' => 'Messages Content'),
),
));
Custom Next, Previous, First, Last Buttons & Progress Bar
$this->widget('bootstrap.widgets.TbWizard', array(
'type' => 'tabs', // 'tabs' or 'pills'
'pagerContent' => '<div style="float:right">
<input type="button" class="btn button-next" name="next" value="Next" />
<input type="button" class="btn button-last" name="last" value="Last" />
</div>
<div style="float:left">
<input type="button" class="btn button-first" name="first" value="First" />
<input type="button" class="btn button-previous" name="previous" value="Previous" />
</div><br /><br />',
'options' => array(
'nextSelector' => '.button-next',
'previousSelector' => '.button-previous',
'firstSelector' => '.button-first',
'lastSelector' => '.button-last',
'onTabShow' => 'js:function(tab, navigation, index) {
var $total = navigation.find("li").length;
var $current = index+1;
var $percent = ($current/$total) * 100;
$("#wizard-bar > .bar").css({width:$percent+"%"});
}',
'onTabClick' => 'js:function(tab, navigation, index) {
alert("Tab Click Disabled");return false;
}',
),
'tabs' => array(
array('label' => 'Home', 'content' => 'Home Content', 'active' => true),
array('label' => 'Profile', 'content' => 'Profile Content'),
array('label' => 'Messages', 'content' => 'Messages Content'),
),
));