TwbBundle, 1.0

Zend Framework 2 module for easy integration of Twitter Bootstrap v2.3.2

This project is maintained by Neilime

TwbBundle, 1.0 - Install / How to

Requirements

Install

Main Setup

By cloning project

  1. Clone this project into your ./vendor/ directory.
  2. (Optionnal) Clone the Twitter bootstrap project (v2.3.2) into your ./vendor/ directory.

With composer

  1. Add this project in your composer.json:

    "require": {
        "neilime/zf2-twb-bundle": "1.0"
    }
    
  2. Now tell composer to download TwbBundle by running the command:

    $ php composer.phar update

Post installation

  1. Enabling it in your application.config.php file.

    return array(
        'modules' => array(
            // ...
            'TwbBundle',
        ),
        // ...
    );
    
  2. Include Twitter Bootstrap assets

With AssetsBundle module (easy way)
Manually

How to use TwbBundle

Simple examples

Features

TwbBundle is abble to render Twitter bootstrap demo site forms, inputs, buttons, & alerts. (tests are written in order to cover what is showed on demo site)

1. Forms

Render \Zend\Form\FormInterface

Form layout :

Layout should be defined when form view helper is invoked

2. Inputs

Render \Zend\Form\ElementInterface

All elements options are defined in twb (array)

new \Zend\Form\Element('test-element',array(
    'twb' => array(
        /** TwbBundle options **/
    )
);

Appended and / or prepended

For all prepended / appended types :

new \Zend\Form\Element('test-element',array(
    'twb' => array(
        'prepend' => array(
            'type' => 'prepended type',
            //Prepended type option
        ),
        'append' => array(
            'type' => 'appended type',
            //Appended type option
        )
    )
);

Form actions

This option allows an element to be in form actions part

//Element in form actions
new \Zend\Form\Element('test-element',array(
    'twb' => array(
        'formAction' => true
    )
);

Help

Validation states

Validations states are only rendered with horizontal form layout, validation status "error" is automatically added when the element contains at least one error message.

//Element with "info" state
new \Zend\Form\Element('test-element',array(
    'twb' => array(
        'state' => 'info'
    )
);

3. Buttons

Render \Zend\Form\Element\Button

Icons

new \Zend\Form\Element\Button('test-button',array(
    'twb' => array(
        'icon' => 'icon-info'
    )
);

Button dropdowns

new \Zend\Form\Element\Button('test-button',array(
    'twb' => array(
        'dropdown' => array(
            'actions' => array(
                /** action options **/
            )
        )
    )
);

Split button dropdowns

new \Zend\Form\Element\Button('test-button',array(
    'twb' => array(
        'dropdown' => array(
            'segmented' => true,
            'actions' => array(
                /** action options **/
            )
        )
    )
);

Right menus

new \Zend\Form\Element\Button('test-button',array(
    'twb' => array(
        'dropdown' => array(
            'pull' => 'right',
            'actions' => array(
                /** action options **/
            )
        )
    )
);

Dropup menus

new \Zend\Form\Element\Button('test-button',array(
    'twb' => array(
        'dropup' => array(
            /** dropup options (same as dropdown **/
        )
    )
);

Actions options

Should be string or array

4. Alerts

Render alerts

Exemple :

//...
$this->alert('Test message','alert-error');
//...    

Params