+ What's Bootstrap-CakePHP-Helpers?
+ Quite simply: It is a collection of CakePHP helpers to generate bootstrap code. The helpers are made
+ to deal with all the 'annoying' bootstrap stuff for you! You never remember what classes you have to add
+ to this specific HTML tag to create a bootstrap form? You won't have to, the BootstrapFormHelper
+ does it for you! You never know what is the template to create a bootstrap modal? The BootstrapModalHelper
+ knows! Check it out!
+ How to set up?
+ To use the helpers, just put them into your View/Helper
folder and add the following
+ lines in your controller:
+
public $helpers = array(
+ 'Html' => 'BootstrapHtml',
+ 'Form' => 'BootstrapForm',
+ 'Modal' => 'BootstrapModal',
+ 'Paginator' => 'BootstrapPaginator'
+) ;
+
+ Because each helper inherit from a base helper (BootstrapHtmlHelper inherits from HtmlHelper),
+ you can (and I recommend) to simply use the bootstrap helpers as the default helpers in your view.
+ How to use?
+ Simply use the helpers as you were used to use (a lot of use... ) the default CakePHP helpers!
+ To create a form, just do:
+echo $this->Form->create('Model') ;
+echo $this->Form->input('fieldname1') ;
+echo $this->Form->input('fieldname2') ;
+echo $this->Form->end('Submit');
+ What the difference from original helpers? Well, the output will have bootstrap template and HTML attributes
+ (see bellow).
+ And that's all?
+ Most of the works is done by redefining the default method in the helpers (such as FormHelper::input
),
+ but a lot of new method (and options for old methods) had been added. See the documentation bellow.
+
+ Documentation
+
+ Important Note
+ A lot of new methods can take an $options
parameter in last position. Most of these method have parameters
+ before the options, but most of the method can take the $options
as a previous parameter, in that case,
+ the type of the parameter will be specified as options|...
. For example the BootstrapHtmlHelper::label
method
+ can either take the $options
parameter in second or third place, so the prototype is label(string $text, options|string $type, array $options)
.
+ BootstrapHtmlHelper
+ The BootstrapHtmlHelper
redefines only one function from the default CakePHP helper but add differents
+ methods.
+
+
icon (string $icon) New!
+
Returns a glyphicon icon.
+
+
Parameters:
+
$icon
The icon to output (see example).
+
+
+
Examples:
+
echo $this->Html->icon('plus') ;
+<i class="glyphicon glyphicon-plus"></i>
+echo $this->Html->icon('pencil') ;
+<i class="glyphicon glyphicon-pencil"></i>
+
+
+
+
label (string $text, options|string $type = 'default', array $options = array()) New!
+
Returns a bootstrap label.
+
+
Parameters:
+
$text
The label text.
+
$type
[Optional] The label type (can be any bootstrap label type,
+ i.e. 'primary'
, 'success'
, etc.).
+
$options
[Optional] The options passed to the HtmlHelper::span
method.
+
+
+
Examples:
+
echo $this->Html->label('label') ;
+<span class="label label-default">label</i>
+echo $this->Html->label('label', 'primary') ;
+<span class="label label-primary">label</i>
+echo $this->Html->label('label', 'success', array('id' => 'mylabelid')) ;
+<span id="mylabelid" class="label label-success">label</i>
+echo $this->Html->label('label', array('class' => 'mylabelclass')) ;
+<span class="mylabelclass label label-default">label</i>
+
+
+
+
badge (string $text, array $options = array()) New!
+
Returns a bootstrap badge.
+
+
Parameters:
+
$text
The badge text.
+
$options
[Optional] The options passed to the HtmlHelper::span
method.
+
+
+
Examples:
+
echo $this->Html->badge('1') ;
+<span class="badge">label</i>
+echo $this->Html->badge('2', array('id' => 'mybadgeid')) ;
+<span id="mybadgeid" class="badge">label</i>
+
+
+
+
getCrumbList (array $options = array(), string $startText = null) Redefinition!
+
This methods just add the correct options to $options before calling HtmlHelper::getCrumbList
, to
+ render a bootstrap crumblist / breadcrumbs (see http://getbootstrap.com/components/#breadcrumbs).
+
+ BootstrapFormHelper
+ BootstrapModalHelper
+ BootstrapPaginatorHelper
+ BootstrapNavbarHelper
+