From ed7bad83195971bacaa503ad00cfc6088a9bf5ea Mon Sep 17 00:00:00 2001 From: neilime Date: Fri, 4 Nov 2016 11:26:06 +0100 Subject: [PATCH 1/6] Update README.md --- README.md | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index cc4638c..cbde029 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,6 @@ Installation 1. Enabling it in your `application.config.php` file. ```php - array( // ... @@ -82,25 +81,21 @@ Installation * Install the [AssetsBundle module](https://github.com/neilime/zf2-twb-bundle/tree/1.0)(1.0) * Install [Twitter Bootstrap](https://github.com/twbs/bootstrap/tree/v2.3.2) (v2.3.2) * Edit the application module configuration file `module/Application/config/module.config.php`, adding the configuration fragment below: - + ```php - array( 'assets' => array( - 'less' => array('@zfRootPath/vendor/twitter/bootstrap/less/bootstrap.less') - ) + 'less' => array('@zfRootPath/vendor/twitter/bootstrap/less/bootstrap.less'), + ), ), //... ); ``` - - * Edit layout file `module/Application/view/layout/layout.phtml`, to render head scripts : - + ```php - headScript(); //... @@ -108,7 +103,7 @@ Installation ###### Manually -* Copy `bootstrap.css` file (available on Twitter Bootstrap website(https://github.com/twbs/bootstrap/archive/v3.0.0.zip) into your assets folder and add it in your head scripts +* Copy `bootstrap.css` file (available on [Twitter Bootstrap website](https://github.com/twbs/bootstrap/archive/v3.0.0.zip)) into your assets folder and add it in your head scripts # How to use __TwbBundle__ @@ -122,13 +117,11 @@ __TwbBundle__ provides view helpers helping render html elements Form helper can be called in a view with the view helper service `form(\Zend\Form\FormInterface $oForm = null, $sFormLayout = \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL)` : ```php -form(new \Zend\Form\Form()); ``` Open form tag with a specific layout : ```php -form(null,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)->openTag($oForm); ``` @@ -143,7 +136,6 @@ The helper auto add form specific class and `form` role attributes. ### Button groups in form Form helper can render button groups in a form row, button elements are grouped by the option `button-group`. Example : ```php -add(new \Zend\Form\Element\Button('left-button', array('label' => 'Left', 'button-group' => 'group-1'))) @@ -153,7 +145,6 @@ $this->form($oForm); If any button belonging to a button group has a `column-size` attribute, then the first occurrence of it will be used for the button group styling. Example : ```php -add(new \Zend\Form\Element\Button('left-button', array('label' => 'Left', 'button-group' => 'group-1', 'column-size' => 'sm-10 col-sm-offset-2'))) @@ -162,7 +153,6 @@ $this->form($oForm); ``` This results in following output : ```html -
``` @@ -171,7 +161,6 @@ This results in following output : Button helper can be called in a view with the view helper service `formButton(\Zend\Form\ElementInterface $oElement, $sButtonContent = null)` : ```php -formButton(new \Zend\Form\Element()); ``` This helper accepts a button element as first param, and an optional button content as second param. @@ -198,7 +187,6 @@ The option `disable-twb` can be passed to the element to disable rendering it in Checkbox helper can be called in a view with the view helper service `formCheckbox(\Zend\Form\Checkbox $oElement)` : ```php -formCheckbox(new \Zend\Form\Element\Checkbox('checkbox-input')); ``` This helper accepts a checkbox element as first param. As the input is rendered into a label element, the label position (append by default) can passed as an option @@ -206,7 +194,6 @@ The option `disable-twb` (boolean) can be passed to the element to disable rende The option `form-group` (boolean) can be passed to the element to force the form-group div container. ```php -formCheckbox(new \Zend\Form\Element\Checkbox('checkbox-input',array( 'label' => 'Prepend label', 'label_options' => array('position' => \Zend\Form\View\Helper\FormRow::LABEL_PREPEND) @@ -218,7 +205,6 @@ $this->formCheckbox(new \Zend\Form\Element\Checkbox('checkbox-input',array( Form collection helper can be called in a view with the view helper service `formCollection(\Zend\Form\ElementInterface $oElement)` : ```php -formCollection(new \Zend\Form\Element()); ``` This helper accepts a form collection (fieldset) element as first param. @@ -228,7 +214,6 @@ This helper accepts a form collection (fieldset) element as first param. Form element helper can be called in a view with the view helper service `formElement(\Zend\Form\ElementInterface $oElement)` : ```php -formElement(new \Zend\Form\Element()); ``` This helper accepts a form element as first param. This helper can render prepend and/or append add-on by setting the appropriate option `add-on-prepend` and/or `add-on-append` to the element. @@ -246,7 +231,6 @@ These options accept the following values : Form element errors helper can be called in a view with the view helper service `formElementErrors(\Zend\Form\ElementInterface $oElement)` : ```php -formElementErrors(new \Zend\Form\Element()); ``` This helper accepts a form element as first param. This helper render element's errors. @@ -256,7 +240,6 @@ This helper accepts a form element as first param. This helper render element's Multi-Checkbox helper can be called in a view with the view helper service `formMultiCheckbox(\Zend\Form\ElementInterface $oElement)` : ```php -formMultiCheckbox(new \Zend\Form\Element\ElementInterface()); ``` This helper accepts an element as first param. @@ -267,7 +250,6 @@ The option `inline` (boolean) can be passed to the element to display checkoxes Radio helper can be called in a view with the view helper service `formCheckbox(\Zend\Form\ElementInterface $oElement)` : ```php -formRadio(new \Zend\Form\Element\ElementInterface()); ``` This helper accepts an element as first param. @@ -280,7 +262,6 @@ The option `btn-group` (boolean) can be passed to the element to display the rad Form element helper can be called in a view with the view helper service `formRow(\Zend\Form\ElementInterface $oElement)` : ```php -formRow(new \Zend\Form\Element()); ``` This helper accepts a form element as first param. @@ -289,14 +270,13 @@ The option `validation-state` (string) can be passed to the element to render th The option `column-size` (int) can be passed to the element to render the row with a defined column size class attribute(`col-lg-...`). The option `help-block` (string) can be passed to the element to render an help block translated appending the element. -If you like to wrap elements into a
in case you want X number of elements on the same line the option `twb-row-open` (bool) can be passed to the element where the row must start and will be printed before the element is rendered. It could be you have to provide the `column-size` in combination with this option. +If you like to wrap elements into a `
` in case you want X number of elements on the same line the option `twb-row-open` (bool) can be passed to the element where the row must start and will be printed before the element is rendered. It could be you have to provide the `column-size` in combination with this option. The option `twb-row-close` (bool) can be passed to the element to close the earlier opened row and will be printed after the elements is rendered. Note: closing earlier opened rows is your responsibility. You can allow the label html rendering after toggling off escape : ```php -formRow(new \Zend\Form\Element('my-element', array( 'label' => 'My Label :', 'label_options' => array('disable_html_escape' => true) @@ -311,15 +291,11 @@ You can also set the the form-group size by passing the `twb-form-group-size` op {{ formRow( f ) }} {% endfor %} ``` - - - #### Static : `TwbBundle\Form\View\Helper\TwbBundleFormStatic` Static helper can be called in a view with the view helper service `formStatic(\Zend\Form\ElementInterface $oElement)` : ```php -formStatic(new \Zend\Form\Element\ElementInterface()); ``` This helper accepts an element as first param. @@ -331,7 +307,6 @@ This helper accepts an element as first param. Alert helper can be called in a view with the view helper service `alert($sAlertMessage = null, $aAlertAttributes = null, $bDismissable = false)` : ```php -alert('alert message',array('class' => 'alert-success')); ``` This helper accepts a message as first param, attributes for alert container as second param (optional) and boolean as third param to display or not a close action to the alert message (optional). @@ -342,7 +317,6 @@ The class attribute "alert" is auto added to the alert container. Badge helper can be called in a view with the view helper service `badge($sBadgeMessage = null, array $aBadgeAttributes = null)` : ```php -badge('badge message',array('class' => 'pull-right')); ``` This helper accepts a message as first param, and attributes for badge container as second param (optional). @@ -353,7 +327,6 @@ The class attribute "badge" is auto added to the badge container. Button group helper can be called in a view with the view helper service `buttonGroup(array $aButtons = null, array $aButtonGroupOptions = null)` : ```php -buttonGroup(array(new \Zend\Form\Element\Button('left', array('label' => 'Left'))),array('class' => 'pull-right')); ``` This helper accepts an array of buttons as first param, and attributes for button group container as second param (optional). @@ -364,7 +337,6 @@ The buttons can be instance of `\Zend\Form\Element\Button` or array containing d Glyphicon helper can be called in a view with the view helper service `glyphicon($sGlyphicon = null, array $aGlyphiconAttributes = null)` : ```php -glyphicon('star',array('class' => 'pull-right')); ``` This helper accepts an icon name as first param (e.g. "star", "search" ...), and attributes for glyphicon element as second param (optional). @@ -375,7 +347,6 @@ The class attribute "glyphicon" is auto added to the glyphicon container. FontAwesome helper can be called in a view with the view helper service `fontAwesome($sFontAwesome = null, array $aFontAwesomeAttributes = null)` : ```php -fontAwesome('star',array('class' => 'pull-right')); ``` This helper accepts an icon name as first param (e.g. "star", "search" ...), and attributes for fontAwesome element as second param (optional). @@ -386,7 +357,6 @@ The class attribute "fa" is auto added to the fontAwesome container. Dropdown helper can be called in a view with the view helper service `dropdown(array $aDropdownOptions = null)` : ```php -dropdown(array('Item #1',\TwbBundle\View\Helper\TwbBundleDropDown::TYPE_ITEM_DIVIDER,'Item #2')); ``` This helper accepts dropdown configuration as first param : @@ -415,14 +385,12 @@ This helper accepts dropdown configuration as first param : Label helper can be called in a view with the view helper service `label($sLabelMessage = null, array $aLabelAttributes = 'label-default')` : ```php -label('label message',array('class' => 'label-primary')); ``` This helper accepts a message as first param, and attributes for label container as second param (optional). The class attribute "label" is auto added to the label container and "label-default" is no attributes is given. Default label container is a span, but it can be changed by passing the tag name in the attributes array : ```php -label('label message',array('class' => 'label-primary','tagName' => 'a')); ``` @@ -468,6 +436,5 @@ __TwbBundle__ provides new elements to supports Twitter Bootstrap potential. Static element is a form element witch provides `Static control` and should be rendered by [static form helper](#static--twbbundleformviewhelpertwbbundleformstatic) ```php -formStatic(new \TwbBundle\Form\Element\StaticElement()); ``` From f065e248816e226eee67d62fcd891830f0cd3424 Mon Sep 17 00:00:00 2001 From: neilime Date: Fri, 4 Nov 2016 11:27:04 +0100 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cbde029..17b78f8 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Installation ```json "require": { - "neilime/zf2-twb-bundle": "2.*@stable" + "neilime/zf2-twb-bundle": "3.*@stable" } ``` From 67ee341e04e2854e39aa76db99ecda651b396ebc Mon Sep 17 00:00:00 2001 From: neilime Date: Fri, 4 Nov 2016 11:55:48 +0100 Subject: [PATCH 3/6] Update README.md --- README.md | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 17b78f8..821d517 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -TwbBundle -===================== +# ZF TwbBundle module + (Supports Twitter Bootstrap v3.*) [![Build Status](https://travis-ci.org/neilime/zf2-twb-bundle.svg?branch=master)](https://travis-ci.org/neilime/zf2-twb-bundle) @@ -12,39 +12,33 @@ NOTE : If you want to contribute don't hesitate, I'll review any PR. Support the project
-Introduction ------------- +# Introduction -__TwbBundle__ is a module for Zend Framework 2 & 3, for easy integration of the [Twitter Bootstrap v3.*](https://github.com/twbs/bootstrap). +__TwbBundle__ is a Zend Framework module for easy integration of the [Twitter Bootstrap v3.*](https://github.com/twbs/bootstrap). -Contributing ------------- +# Contributing If you wish to contribute to TwbBundle, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file. -Demonstration / example ------------------------ +# Demonstration / example Render forms, buttons, alerts with TwbBundle : see it in action [on-line](http://neilime.github.io/zf2-twb-bundle/demo.html). - -Requirements ------------- +# Requirements * [Zend Framework 2 or 3](https://github.com/zendframework/zendframework) (2.* || 3.*) * [Twitter Bootstrap](https://github.com/twbs/bootstrap) (v3.*) -Installation ------------- +# Installation -### Main Setup +## Main Setup -#### By cloning project (manual) +### By cloning project (manual) 1. Clone this project into your `./vendor/` directory. 2. (Optional) Clone the [Twitter bootstrap project](https://github.com/twbs/bootstrap) (v3.*) into your `./vendor/` directory. -#### With composer (the faster way) +### With composer (the faster way) 1. Add this project in your composer.json: @@ -60,7 +54,7 @@ Installation $ php composer.phar update ``` -#### Post installation +### Post installation 1. Enabling it in your `application.config.php` file. @@ -76,7 +70,7 @@ Installation 2. Include Twitter Bootstrap assets -###### With __AssetsBundle__ module (easy way) +##### With __AssetsBundle__ module (easy way) * Install the [AssetsBundle module](https://github.com/neilime/zf2-twb-bundle/tree/1.0)(1.0) * Install [Twitter Bootstrap](https://github.com/twbs/bootstrap/tree/v2.3.2) (v2.3.2) @@ -101,7 +95,7 @@ Installation //... ``` -###### Manually +##### Manually * Copy `bootstrap.css` file (available on [Twitter Bootstrap website](https://github.com/twbs/bootstrap/archive/v3.0.0.zip)) into your assets folder and add it in your head scripts From ba5dfab4026ab36082450b7f3258700044fdd7d5 Mon Sep 17 00:00:00 2001 From: neilime Date: Fri, 4 Nov 2016 11:58:10 +0100 Subject: [PATCH 4/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 821d517..f394223 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ZF TwbBundle module +# TwbBundle - Zend Framework module (Supports Twitter Bootstrap v3.*) From 23eb61574d1c2ee70783398e44bcadfbf3e87aa6 Mon Sep 17 00:00:00 2001 From: neilime Date: Fri, 4 Nov 2016 13:19:52 +0100 Subject: [PATCH 5/6] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f394223..dd0341b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # TwbBundle - Zend Framework module -(Supports Twitter Bootstrap v3.*) +__TwbBundle__ is a Zend Framework module for easy integration of the [Twitter Bootstrap v3.*](https://github.com/twbs/bootstrap) (Supports Twitter Bootstrap v3.*). [![Build Status](https://travis-ci.org/neilime/zf2-twb-bundle.svg?branch=master)](https://travis-ci.org/neilime/zf2-twb-bundle) [![Coverage Status](https://coveralls.io/repos/github/neilime/zf2-twb-bundle/badge.svg)](https://coveralls.io/github/neilime/zf2-twb-bundle) @@ -8,17 +8,17 @@ [![Total Downloads](https://poser.pugx.org/neilime/zf2-twb-bundle/downloads.png)](https://packagist.org/packages/neilime/zf2-twb-bundle) [![Dependency Status](https://www.versioneye.com/user/projects/5294fa9d632bac5a67000046/badge.png)](https://www.versioneye.com/user/projects/5294fa9d632bac5a67000046) -NOTE : If you want to contribute don't hesitate, I'll review any PR. +# Helping Project -Support the project
+If this project helps you reduce time to develop and/or you want to help the maintainer of this project, you can make a donation, thank you. -# Introduction -__TwbBundle__ is a Zend Framework module for easy integration of the [Twitter Bootstrap v3.*](https://github.com/twbs/bootstrap). +Support the project
# Contributing If you wish to contribute to TwbBundle, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file. +NOTE : If you want to contribute don't hesitate, I'll review any PR. # Demonstration / example From a5ec64d368a28dc419a8a60aa36de6e6b9685ccb Mon Sep 17 00:00:00 2001 From: neilime Date: Sun, 6 Nov 2016 19:01:55 +0100 Subject: [PATCH 6/6] Update README.md --- README.md | 429 +++--------------------------------------------------- 1 file changed, 22 insertions(+), 407 deletions(-) diff --git a/README.md b/README.md index dd0341b..c273472 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ __TwbBundle__ is a Zend Framework module for easy integration of the [Twitter Bo If this project helps you reduce time to develop and/or you want to help the maintainer of this project, you can make a donation, thank you. - Support the project
# Contributing @@ -26,409 +25,25 @@ Render forms, buttons, alerts with TwbBundle : see it in action [on-line](http:/ # Requirements -* [Zend Framework 2 or 3](https://github.com/zendframework/zendframework) (2.* || 3.*) -* [Twitter Bootstrap](https://github.com/twbs/bootstrap) (v3.*) - -# Installation - -## Main Setup - -### By cloning project (manual) - -1. Clone this project into your `./vendor/` directory. -2. (Optional) Clone the [Twitter bootstrap project](https://github.com/twbs/bootstrap) (v3.*) into your `./vendor/` directory. - -### With composer (the faster way) - -1. Add this project in your composer.json: - - ```json - "require": { - "neilime/zf2-twb-bundle": "3.*@stable" - } - ``` - -2. Now tell composer to download __TwbBundle__ by running the command: - - ```bash - $ php composer.phar update - ``` - -### Post installation - -1. Enabling it in your `application.config.php` file. - - ```php - return array( - 'modules' => array( - // ... - 'TwbBundle', - ), - // ... - ); - ``` - -2. Include Twitter Bootstrap assets - -##### With __AssetsBundle__ module (easy way) - -* Install the [AssetsBundle module](https://github.com/neilime/zf2-twb-bundle/tree/1.0)(1.0) -* Install [Twitter Bootstrap](https://github.com/twbs/bootstrap/tree/v2.3.2) (v2.3.2) -* Edit the application module configuration file `module/Application/config/module.config.php`, adding the configuration fragment below: - - ```php - return array( - //... - 'assets_bundle' => array( - 'assets' => array( - 'less' => array('@zfRootPath/vendor/twitter/bootstrap/less/bootstrap.less'), - ), - ), - //... - ); - ``` -* Edit layout file `module/Application/view/layout/layout.phtml`, to render head scripts : - - ```php - //... - echo $this->headScript(); - //... - ``` - -##### Manually - -* Copy `bootstrap.css` file (available on [Twitter Bootstrap website](https://github.com/twbs/bootstrap/archive/v3.0.0.zip)) into your assets folder and add it in your head scripts - -# How to use __TwbBundle__ - -## View helpers - -__TwbBundle__ provides view helpers helping render html elements - -### Forms - -#### Form : `TwbBundle\Form\View\Helper\TwbBundleForm` - -Form helper can be called in a view with the view helper service `form(\Zend\Form\FormInterface $oForm = null, $sFormLayout = \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL)` : -```php -$this->form(new \Zend\Form\Form()); -``` - -Open form tag with a specific layout : -```php -$this->form(null,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)->openTag($oForm); -``` - -This helper accepts a form element as first param, and an optional Bootstrap defined layout style definition as second param. -Here are the available layouts : - -* `TwbBundle\Form\View\Helper::LAYOUT_HORIZONTAL` : horizontal (default) -* `TwbBundle\Form\View\Helper::LAYOUT_INLINE` : inline - -The helper auto add form specific class and `form` role attributes. - -### Button groups in form -Form helper can render button groups in a form row, button elements are grouped by the option `button-group`. Example : -```php -$oForm = new \Zend\Form\Form(); -$oForm - ->add(new \Zend\Form\Element\Button('left-button', array('label' => 'Left', 'button-group' => 'group-1'))) - ->add(new \Zend\Form\Element\Button('right-button', array('label' => 'Right', 'button-group' => 'group-1'))); -$this->form($oForm); -``` - -If any button belonging to a button group has a `column-size` attribute, then the first occurrence of it will be used for the button group styling. Example : -```php -$oForm = new \Zend\Form\Form(); -$oForm - ->add(new \Zend\Form\Element\Button('left-button', array('label' => 'Left', 'button-group' => 'group-1', 'column-size' => 'sm-10 col-sm-offset-2'))) - ->add(new \Zend\Form\Element\Button('right-button', array('label' => 'Right', 'button-group' => 'group-1'))); -$this->form($oForm); -``` -This results in following output : -```html -
-``` - -#### Button : `TwbBundle\Form\View\Helper\TwbBundleFormButton` - -Button helper can be called in a view with the view helper service `formButton(\Zend\Form\ElementInterface $oElement, $sButtonContent = null)` : - -```php -$this->formButton(new \Zend\Form\Element()); -``` -This helper accepts a button element as first param, and an optional button content as second param. -It auto add button specific class (`btn` & `btn-default` is no button class is defined) attribute. - -The option `glyphicon` (string or array) and `fontAwesome` (string or array) can be defined to render a glyphicon or a fontAwesome icon into the element : -The glyphicon is rendered by the [glyphicon renderer](#glyphicon--twbbundleviewhelpertwbbundleglyphicon). -The fontAwesome is rendered by the [fontAwesome renderer](#fontawesome--twbbundleviewhelpertwbbundlefontawesome). - -If the option is a string, it should be the name of the icon (e.g. "star", "search" ...), the glyphicon will prepend the label if exists. If the option is an array, it accept the folling options : -* string `icon` : the name of the icon (e.g. "star", "search" ...). -* string `position` : (optional) the position of the glyphicon to prepend or append the button content, `\TwbBundle\Form\View\Helper\TwbBundleFormButton::GLYPHICON_PREPEND` (the default) and `\TwbBundle\Form\View\Helper\TwbBundleFormButton::GLYPHICON_APPEND`. -* array `attributes` : (optional) the additional attributes to the glyphicon element - -Button can be set as dropdown button by defined the option `dropdown` (array) to the element : -The dropdown is rendered by the [dropdown renderer](#dropdown--twbbundleviewhelpertwbbundledropdown), it accept the folling additionnal options : -* boolean `split` : the button element and the carret are splitted. -* boolean `dropup` : render a dropup element instead of a dropdown. - -The option `disable-twb` can be passed to the element to disable rendering it in a `div` container. - -#### Checkbox : `TwbBundle\Form\View\Helper\TwbBundleFormCheckbox` - -Checkbox helper can be called in a view with the view helper service `formCheckbox(\Zend\Form\Checkbox $oElement)` : - -```php -$this->formCheckbox(new \Zend\Form\Element\Checkbox('checkbox-input')); -``` -This helper accepts a checkbox element as first param. As the input is rendered into a label element, the label position (append by default) can passed as an option -The option `disable-twb` (boolean) can be passed to the element to disable rendering it in a `label`. -The option `form-group` (boolean) can be passed to the element to force the form-group div container. - -```php -$this->formCheckbox(new \Zend\Form\Element\Checkbox('checkbox-input',array( - 'label' => 'Prepend label', - 'label_options' => array('position' => \Zend\Form\View\Helper\FormRow::LABEL_PREPEND) -))); -``` - -#### Form collection : `TwbBundle\Form\View\Helper\TwbBundleFormCollection` - -Form collection helper can be called in a view with the view helper service `formCollection(\Zend\Form\ElementInterface $oElement)` : - -```php -$this->formCollection(new \Zend\Form\Element()); -``` -This helper accepts a form collection (fieldset) element as first param. - -#### Form element : `TwbBundle\Form\View\Helper\TwbBundleFormElement` - -Form element helper can be called in a view with the view helper service `formElement(\Zend\Form\ElementInterface $oElement)` : - -```php -$this->formElement(new \Zend\Form\Element()); -``` -This helper accepts a form element as first param. This helper can render prepend and/or append add-on by setting the appropriate option `add-on-prepend` and/or `add-on-append` to the element. -These options accept the following values : -* `Zend\Form\ElementInterface` : the element will be rendered in the add-on -* `scalar` : the value will be translated and rendered in the add-on -* `array` : - The array accept once of the following keys : - * `text` (scalar) : the value will be translated and rendered in the add-on - * `element` (array) : An element will be created by \Zend\Form\Factory and the given array, then rendered in the add-on - * `element` (Zend\Form\ElementInterface) : the element will be rendered in the add-on - -#### Form element errors : `TwbBundle\Form\View\Helper\TwbBundleFormElementErrors` - -Form element errors helper can be called in a view with the view helper service `formElementErrors(\Zend\Form\ElementInterface $oElement)` : - -```php -$this->formElementErrors(new \Zend\Form\Element()); -``` -This helper accepts a form element as first param. This helper render element's errors. - -#### Multi-Checkbox : `TwbBundle\Form\View\Helper\TwbBundleFormMultiCheckbox` - -Multi-Checkbox helper can be called in a view with the view helper service `formMultiCheckbox(\Zend\Form\ElementInterface $oElement)` : - -```php -$this->formMultiCheckbox(new \Zend\Form\Element\ElementInterface()); -``` -This helper accepts an element as first param. -The option `inline` (boolean) can be passed to the element to display checkoxes inlined (default) or not. - -#### Radio : `TwbBundle\Form\View\Helper\TwbBundleFormRadio` - -Radio helper can be called in a view with the view helper service `formCheckbox(\Zend\Form\ElementInterface $oElement)` : - -```php -$this->formRadio(new \Zend\Form\Element\ElementInterface()); -``` -This helper accepts an element as first param. -The option `disable-twb` (boolean) can be passed to the element to disable rendering it in a `div` container. -The option `inline` (boolean) can be passed to the element to display radio inlined or not (default). -The option `btn-group` (boolean) can be passed to the element to display the radio options as a button group or not (default). - -#### Form row : `TwbBundle\Form\View\Helper\TwbBundleFormRow` - -Form element helper can be called in a view with the view helper service `formRow(\Zend\Form\ElementInterface $oElement)` : - -```php -$this->formRow(new \Zend\Form\Element()); -``` -This helper accepts a form element as first param. -The option `twb-layout` (string) can be passed to the element to render the row with a defined layout style as [form helper](#form--twbbundleformviewhelpertwbbundleform). -The option `validation-state` (string) can be passed to the element to render the row with a defined validation state class attribute(`has-...`). If the element has messages, `has-error` class attribute is auto added. -The option `column-size` (int) can be passed to the element to render the row with a defined column size class attribute(`col-lg-...`). -The option `help-block` (string) can be passed to the element to render an help block translated appending the element. - -If you like to wrap elements into a `
` in case you want X number of elements on the same line the option `twb-row-open` (bool) can be passed to the element where the row must start and will be printed before the element is rendered. It could be you have to provide the `column-size` in combination with this option. -The option `twb-row-close` (bool) can be passed to the element to close the earlier opened row and will be printed after the elements is rendered. -Note: closing earlier opened rows is your responsibility. - -You can allow the label html rendering after toggling off escape : - -```php -$this->formRow(new \Zend\Form\Element('my-element', array( - 'label' => 'My Label :', - 'label_options' => array('disable_html_escape' => true) -))); -``` - -You can also set the the form-group size by passing the `twb-form-group-size` option on the element passed to formRow, example Twig syntax: - -```twig -{% for f in server_form %} - {% do f.setOption( 'twb-form-group-size', 'form-group-sm' ) %} - {{ formRow( f ) }} -{% endfor %} -``` -#### Static : `TwbBundle\Form\View\Helper\TwbBundleFormStatic` - -Static helper can be called in a view with the view helper service `formStatic(\Zend\Form\ElementInterface $oElement)` : - -```php -$this->formStatic(new \Zend\Form\Element\ElementInterface()); -``` -This helper accepts an element as first param. - -### Mixed - -#### Alert : `TwbBundle\View\Helper\TwbBundleAlert` - -Alert helper can be called in a view with the view helper service `alert($sAlertMessage = null, $aAlertAttributes = null, $bDismissable = false)` : - -```php -$this->alert('alert message',array('class' => 'alert-success')); -``` -This helper accepts a message as first param, attributes for alert container as second param (optional) and boolean as third param to display or not a close action to the alert message (optional). -The class attribute "alert" is auto added to the alert container. - -#### Badge : `TwbBundle\View\Helper\TwbBundleBadge` - -Badge helper can be called in a view with the view helper service `badge($sBadgeMessage = null, array $aBadgeAttributes = null)` : - -```php -$this->badge('badge message',array('class' => 'pull-right')); -``` -This helper accepts a message as first param, and attributes for badge container as second param (optional). -The class attribute "badge" is auto added to the badge container. - -#### Button group : `TwbBundle\View\Helper\TwbBundleButtonGroup` - -Button group helper can be called in a view with the view helper service `buttonGroup(array $aButtons = null, array $aButtonGroupOptions = null)` : - -```php -$this->buttonGroup(array(new \Zend\Form\Element\Button('left', array('label' => 'Left'))),array('class' => 'pull-right')); -``` -This helper accepts an array of buttons as first param, and attributes for button group container as second param (optional). -The buttons can be instance of `\Zend\Form\Element\Button` or array containing data to build an element with the `\Zend\Form\Factory` - -#### Glyphicon : `TwbBundle\View\Helper\TwbBundleGlyphicon` - -Glyphicon helper can be called in a view with the view helper service `glyphicon($sGlyphicon = null, array $aGlyphiconAttributes = null)` : - -```php -$this->glyphicon('star',array('class' => 'pull-right')); -``` -This helper accepts an icon name as first param (e.g. "star", "search" ...), and attributes for glyphicon element as second param (optional). -The class attribute "glyphicon" is auto added to the glyphicon container. - -#### FontAwesome : `TwbBundle\View\Helper\TwbBundleFontAwesome` - -FontAwesome helper can be called in a view with the view helper service `fontAwesome($sFontAwesome = null, array $aFontAwesomeAttributes = null)` : - -```php -$this->fontAwesome('star',array('class' => 'pull-right')); -``` -This helper accepts an icon name as first param (e.g. "star", "search" ...), and attributes for fontAwesome element as second param (optional). -The class attribute "fa" is auto added to the fontAwesome container. - -#### Dropdown : `TwbBundle\View\Helper\TwbBundleDropDown` - -Dropdown helper can be called in a view with the view helper service `dropdown(array $aDropdownOptions = null)` : - -```php -$this->dropdown(array('Item #1',\TwbBundle\View\Helper\TwbBundleDropDown::TYPE_ITEM_DIVIDER,'Item #2')); -``` -This helper accepts dropdown configuration as first param : - * `attributes` (array) : attributes for the dropdown container (optional) - * `label` (scalar) : Label content (will be translated), may be empty (optional) - * `toggle_attributes` (array) : attributes for the dropdown toggle container (optional) - * `items` (array) : list of items, should contains : - * `scalar` : - * `\TwbBundle\View\Helper\TwbBundleDropDown::TYPE_ITEM_DIVIDER` : display a divider - * `text` : display a text (translated) into a link (anchor attribute is the same as content) - * `array` : the item options : - * `type` (string) : the type of item - * `\TwbBundle\View\Helper\TwbBundleDropDown::TYPE_ITEM_HEADER` : render an item as header - It needs the following option : - * `label` (scalar) content text (translated) of the item - * `\TwbBundle\View\Helper\TwbBundleDropDown::TYPE_ITEM_DIVIDER` : render a divider - * `\TwbBundle\View\Helper\TwbBundleDropDown::TYPE_ITEM_LINK` : render an item as a link `` - It needs the following option : - * `label` (scalar) content text (translated) of the item - * `item_attributes` (array) : attributes for the item container (optional) - * `attributes` (array) : the attributes of the item container - * `list_attributes` (array) : attributes for the dropdown list container (optional) - -#### Label : `TwbBundle\View\Helper\TwbBundleLabel` - -Label helper can be called in a view with the view helper service `label($sLabelMessage = null, array $aLabelAttributes = 'label-default')` : - -```php -$this->label('label message',array('class' => 'label-primary')); -``` -This helper accepts a message as first param, and attributes for label container as second param (optional). -The class attribute "label" is auto added to the label container and "label-default" is no attributes is given. Default label container is a span, but it can be changed by passing the tag name in the attributes array : - -```php -$this->label('label message',array('class' => 'label-primary','tagName' => 'a')); -``` - -## Options - -### Ignore custom view helpers - -By default, this module tries to add form-control class to every form element. There are some elements, like checkboxes, radios and buttons, that does not use that class in bootstrap. This config allows you to tell the render method to ignore your custom form view helper and do NOT add that class. - -```php - return [ - 'twbbundle' => [ - 'ignoredViewHelpers' => [ - 'viewhelpername', - ], - ] - ]; -``` - -### Add instance maps and type maps to view helper - -This config options allow to change instance and type map to FormElement class. That functional is good approach when new elements (or elements and them viewhelpers) are added into your project. - -```php - return [ - 'twbbundle' => [ - 'type_map' => [ - 'help_words' => 'formhelpwords', - ], - 'class_map' => [ - 'Application\Form\Element\HelpWords' => 'formhelpwords', - ], - ] - ]; -``` - -## Elements - -__TwbBundle__ provides new elements to supports Twitter Bootstrap potential. - -#### StaticElement : `TwbBundle\Form\Element\StaticElement` - -Static element is a form element witch provides `Static control` and should be rendered by [static form helper](#static--twbbundleformviewhelpertwbbundleformstatic) - -```php -$this->formStatic(new \TwbBundle\Form\Element\StaticElement()); -``` +Name | Version +-----|-------- +[php](https://secure.php.net/) | >=5.3.3 +[zendframework/zend-config](https://github.com/zendframework/zend-config) | 2.3.9 +[zendframework/zend-escaper](https://github.com/zendframework/zend-escaper) | 2.3.9 +[zendframework/zend-form](https://github.com/zendframework/zend-form) | 2.3.9 +[zendframework/zend-i18n](https://github.com/zendframework/zend-i18n) | 2.3.9 +[zendframework/zend-loader](https://github.com/zendframework/zend-loader) | 2.3.9 +[zendframework/zend-log](https://github.com/zendframework/zend-log) | 2.3.9 +[zendframework/zend-modulemanager](https://github.com/zendframework/zend-modulemanager) | 2.3.9 +[zendframework/zend-mvc](https://github.com/zendframework/zend-mvc) | 2.3.9 +[zendframework/zend-serializer](https://github.com/zendframework/zend-serializer) | 2.3.9 +[zendframework/zend-servicemanager](https://github.com/zendframework/zend-servicemanager) | 2.3.9 +[zendframework/zend-stdlib](https://github.com/zendframework/zend-stdlib) | 2.3.9 +[zendframework/zend-view](https://github.com/zendframework/zend-view) | 2.3.9 + +# Documentation + +1. [Installation](https://github.com/neilime/zf2-twb-bundle/wiki/1.-Installation) +2. [View Helpers](https://github.com/neilime/zf2-twb-bundle/wiki/2.-View-Helpers) +3. [Elements](https://github.com/neilime/zf2-twb-bundle/wiki/3.-Elements) +4. [Global Options](https://github.com/neilime/zf2-twb-bundle/wiki/4.-Global-Options)