Introduction
This module intends to integrate Twitter Bootstrap with Zend Framework 2 and
offers general view helpers, navigation view helpers and form view helpers., (*1)
Requirements
This module uses AssetManager, and
by default, comes set up to use YuiCompressor
to compress assets., (*2)
Installation
Installation of this module uses composer., (*3)
php composer.phar require ise/ise-module-bootstrap
Then add the following modules into your Zend Framework configuration.
- AssetManager
- Ise\Bootstrap, (*4)
Usage
The following form view helpers are registered by default, which override those
provided by Zend Framework, and can be used in their place. All elements will
have the appropriate bootstrap style classes added to them.
- Form
- FormButton
- FormCheckbox
- FormColor
- FormDate
- FormDateSelect
- FormDateTime
- FormDateTimeLocal
- FormDateTimeSelect
- FormDescription
- FormElementErrors
- FormEmail
- FormFile
- FormImage
- FormInput
- FormMonth
- FormMonthSelect
- FormMultiCheckbox
- FormNumber
- FormPassword
- FormRange
- FormRow
- FormSearch
- FormSelect
- FormTel
- FormText
- FormTime
- FormUrl
- FormWeek, (*5)
An entire form can easily be rendered as follows:, (*6)
/**
* Where $form implements Zend\Form\FormInterface
*/
echo $this->form($form);
View Helpers
The bootstrap CSS/JS and meta tags are added by usage of a DispatchListener. The
following view helpers are registered by default.
- Alert
- Badge
- FlashMessenger
- Icon
- Label
- Time, (*7)
Note: The Time plugin uses jQuery Timeago to
display time as "2 minutes ago" for instance., (*8)
Navigation View Helpers
The following navigation view helpers are registered by default.
- Navbar, (*9)
You can use the navbar helper as follows:, (*10)
/**
* Where $container is a valid navigation container name, such as
* 'default_navigation', if using the default ZF2 navigation factory.
*
* To have some of the links floated to the right (a login button for instance),
* you can pass in the 'rightMenu' option to point to another navigation
* container instance.
*/
echo $this->navigation($container)->navbar()->render(null, [
'brand' => [
'label' => 'Your Brand Name Here',
'route' => 'home',
'icon' => 'th-large', // Or any other icon name that would be prefixed glyphicon-*
],
'inverse' => true,
'fixed' => 'top',
'rightMenu' => $anotherContainer,
]);
Credits
Made by Internalsystemerror Limited, and
released under the BSD 3-Clause License, (*11)