Skip to content

Commit

Permalink
Merge dev branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ajfranzoia committed Jul 4, 2014
2 parents eb382a0 + 08b2b3c commit 14a3e58
Show file tree
Hide file tree
Showing 10 changed files with 774 additions and 451 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ php:
- 5.5

env:
- CAKE_VERSION=2.4.6
- CAKE_VERSION=2.4.7
- CAKE_VERSION=2.4.8
- CAKE_VERSION=2.4.9
- CAKE_VERSION=2.5.0
- CAKE_VERSION=2.5.1
- CAKE_VERSION=2.5.2

before_script:
- sh -c "mysql -e 'CREATE DATABASE cakephp_test;'"
- git clone git://github.com/cakephp/cakephp ../cakephp && cd ../cakephp && git checkout $CAKE_VERSION
- cp -R ../cakephp-bootstrap3-helpers plugins/Bs3Helpers
- chmod -R 777 ../cakephp/app/tmp
- composer global require 'phpunit/phpunit=3.7.33'
- ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ../cakephp/vendors/PHPUnit
- chmod -R 777 ../cakephp/app/tmp
- echo "<?php
class DATABASE_CONFIG {
public \$test = array(
Expand Down
29 changes: 29 additions & 0 deletions Config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* Default options for inputs.
* Used by default FormHelper class.
*
* @var array
*/

Configure::write('Bs3.Form.styles', array(
'horizontal' => array(
'formDefaults' => array(
'submitDiv' => 'col-sm-10 col-sm-offset-2'
),
'inputDefaults' => array(
'label' => array(
'class' => 'col-sm-2 control-label'
),
'wrap' => 'col-sm-10',
)
),
'inline' => array(
'inputDefaults' => array(
'label' => array(
'class' => 'sr-only'
),
)
)
));
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 QTSdev
Copyright (c) 2014 Codaxis

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
94 changes: 84 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,97 @@
CakePHP Bootstrap 3 FormHelper
=============================

Version 1.0
Yet another Cake 2.x form helper, but with minimal coding and highly configurable.

[![Build Status](https://travis-ci.org/Codaxis/cakephp-bootstrap3-helpers.svg?branch=master)](https://travis-ci.org/Codaxis/bootstrap3-helpers)
Feel free to make any code/docs contributions or post any issues.

Yet another Cake form helper, but with minimal coding and highly configurable.
[![Build Status](https://travis-ci.org/Codaxis/cakephp-bootstrap3-helpers.svg?branch=master)](https://travis-ci.org/Codaxis/cakephp-bootstrap3-helpers)

Compatible with Cake 2.4.6+
## Installation

Feel free to make any code/docs contributions or post any issues.
1. Install with composer by running `composer require codaxis/cakephp-bootstrap3-helpers:1.1` or clone/copy files into `app/Plugin/Bs3Helpers`

2. Include the plugin in your bootstrap.php with `CakePlugin::load('Bs3Helpers')` or `CakePlugin::load('Bs3Helpers', array('bootstrap' => true))` to load included default Bootstrap form styles.

3. Load helper in your ```AppController```. Use classname option if you want to keep your helper alias as Form.

```php
// In AppController.php
public $helpers = array('Bs3Helpers.Bs3FormHelper');
// or
public $helpers = array('Form' => array('className' => 'Bs3Helpers.Bs3FormHelper'));
```

4. Define your custom form styles at wish in your bootstrap.php


## Form helper usage options

**BsFormHelper::create() custom options:**

- ```formStyle``` => shortcut for custom form styles. E.g.: ```formStyle => inline``` will add 'form-inline' class to form tag

- ```submitDiv``` => if set, will enable end() method div option and set passed div class. Useful to be used gloabally or with a defined form style

**Bs3FormHelper::input() default base options:**

- ```class``` => ```'form-control'```
- ```div``` => ```array('class' => 'form-group')```
- ```label``` => ```array('class' => 'control-label')```
- ```error``` => ```array('attributtes' => 'array('class' => 'help-block'))```


**Bs3FormHelper::input() custom options:**

- ```beforeInput``` => html code to prepend right before the input.
- ```afterInput``` => html code to append right after the input.
- ```wrap``` => if set, will wrap the form input inside a div with the css class passed.
Useful for input sizing.
- ```help``` => help text to show after input. Will be rendered inside a div with .help-block class.
- ```errorClass``` => Error class for .form-group div. Defaults to 'has-error'.
- ```errorsAlwaysAsList``` => if set to true, will render error messages always inside as list, no matter if there's only one error. Useful to ensure ui consistency.
- ```feedback``` => allows feedback icons in text inputs, passing ```fa-icon-name``` or ```glyphicon-icon-name``` will render the full ```<i>``` tag.
- ```inputGroup``` => array options that supports the following params:
- ```size``` => can be ```sm``` or ```lg```
- ```prepend```: html code to prepend. If it starts with ```fa``` or ```glyphicon```, will be interpreted as an icon and the full icon tag will be rendered.
- ```append```: html code to prepend. If it starts with ```fa``` or ```glyphicon```, will be interpreted as an icon and the full icon tag will be rendered.
- ```externalWrap``` => if set, the whole input div (without taking into account .help-block) will be wrapped inside another div with the given class will be applied, preventing unnecessary shrinking in some cases. Solves this issue https://github.com/twbs/bootstrap/issues/9694.
- ```checkboxLabel```: if set, will wrap a single checkbox inside a ```div.checkbox``` and a ```label``` with the passed text.
- ```inline``` => used in conjuntion with checkbox and radio groups to allow inline display.


## Global form styles

Global form styles can be defined in bootstrap.php and used anywhere by passing the ```formStyle``` option in create() method.

Inbuilt styles horizontal and inline included are defined like:

---
#### Version 1.1 in progress, will be released soon
---
```php
Configure::write('Bs3.Form.styles', array(
'horizontal' => array(
'formDefaults' => array(
'submitDiv' => 'col-sm-10 col-sm-offset-2'
),
'inputDefaults' => array(
'label' => array(
'class' => 'col-sm-2 control-label'
),
'wrap' => 'col-sm-10',
)
),
'inline' => array(
'inputDefaults' => array(
'label' => array(
'class' => 'sr-only'
),
)
)
));
```

## How to use
## Html helper usage options

Usage instructions and extensive examples can be found at http://bs3form.codaxis.com
TODO

## License

Expand Down
17 changes: 6 additions & 11 deletions Test/Case/AllTestsTest.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
<?php
/**
* AllTestsTest file
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Codaxis (http://codaxis.com)
* @author augusto-cdxs (https://github.com/augusto-cdxs/
* @link https://github.com/Codaxis/parsley-helper ParsleyHelper
* @package ParsleyHelper.Test.Case
* @author Codaxis (https://github.com/Codaxis/
* @link https://github.com/Codaxis/cakephp-bootstrap3-helpers
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

/**
* AllTestsTest class
*
* This test group will run ParsleyFormHelperTest and ParsleyFormTraitTest only
* if version greather than 5.4.
*
* @package ParsleyHelper.Test.Case
*/
class AllTestsTest extends PHPUnit_Framework_TestSuite {

Expand All @@ -32,4 +27,4 @@ public static function suite() {
$suite->addTestDirectory($path);
return $suite;
}
}
}
Loading

0 comments on commit 14a3e58

Please sign in to comment.