Skip to content

Commit 14a3e58

Browse files
committed
Merge dev branch
2 parents eb382a0 + 08b2b3c commit 14a3e58

10 files changed

+774
-451
lines changed

.travis.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ php:
66
- 5.5
77

88
env:
9-
- CAKE_VERSION=2.4.6
10-
- CAKE_VERSION=2.4.7
11-
- CAKE_VERSION=2.4.8
12-
- CAKE_VERSION=2.4.9
9+
- CAKE_VERSION=2.5.0
10+
- CAKE_VERSION=2.5.1
11+
- CAKE_VERSION=2.5.2
1312

1413
before_script:
1514
- sh -c "mysql -e 'CREATE DATABASE cakephp_test;'"
1615
- git clone git://github.com/cakephp/cakephp ../cakephp && cd ../cakephp && git checkout $CAKE_VERSION
1716
- cp -R ../cakephp-bootstrap3-helpers plugins/Bs3Helpers
17+
- chmod -R 777 ../cakephp/app/tmp
1818
- composer global require 'phpunit/phpunit=3.7.33'
1919
- ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ../cakephp/vendors/PHPUnit
20-
- chmod -R 777 ../cakephp/app/tmp
2120
- echo "<?php
2221
class DATABASE_CONFIG {
2322
public \$test = array(

Config/bootstrap.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* Default options for inputs.
5+
* Used by default FormHelper class.
6+
*
7+
* @var array
8+
*/
9+
10+
Configure::write('Bs3.Form.styles', array(
11+
'horizontal' => array(
12+
'formDefaults' => array(
13+
'submitDiv' => 'col-sm-10 col-sm-offset-2'
14+
),
15+
'inputDefaults' => array(
16+
'label' => array(
17+
'class' => 'col-sm-2 control-label'
18+
),
19+
'wrap' => 'col-sm-10',
20+
)
21+
),
22+
'inline' => array(
23+
'inputDefaults' => array(
24+
'label' => array(
25+
'class' => 'sr-only'
26+
),
27+
)
28+
)
29+
));

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 QTSdev
3+
Copyright (c) 2014 Codaxis
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

+84-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,97 @@
11
CakePHP Bootstrap 3 FormHelper
22
=============================
33

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

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

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

10-
Compatible with Cake 2.4.6+
10+
## Installation
1111

12-
Feel free to make any code/docs contributions or post any issues.
12+
1. Install with composer by running `composer require codaxis/cakephp-bootstrap3-helpers:1.1` or clone/copy files into `app/Plugin/Bs3Helpers`
13+
14+
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.
15+
16+
3. Load helper in your ```AppController```. Use classname option if you want to keep your helper alias as Form.
17+
18+
```php
19+
// In AppController.php
20+
public $helpers = array('Bs3Helpers.Bs3FormHelper');
21+
// or
22+
public $helpers = array('Form' => array('className' => 'Bs3Helpers.Bs3FormHelper'));
23+
```
24+
25+
4. Define your custom form styles at wish in your bootstrap.php
26+
27+
28+
## Form helper usage options
29+
30+
**BsFormHelper::create() custom options:**
31+
32+
- ```formStyle``` => shortcut for custom form styles. E.g.: ```formStyle => inline``` will add 'form-inline' class to form tag
33+
34+
- ```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
35+
36+
**Bs3FormHelper::input() default base options:**
37+
38+
- ```class``` => ```'form-control'```
39+
- ```div``` => ```array('class' => 'form-group')```
40+
- ```label``` => ```array('class' => 'control-label')```
41+
- ```error``` => ```array('attributtes' => 'array('class' => 'help-block'))```
42+
43+
44+
**Bs3FormHelper::input() custom options:**
45+
46+
- ```beforeInput``` => html code to prepend right before the input.
47+
- ```afterInput``` => html code to append right after the input.
48+
- ```wrap``` => if set, will wrap the form input inside a div with the css class passed.
49+
Useful for input sizing.
50+
- ```help``` => help text to show after input. Will be rendered inside a div with .help-block class.
51+
- ```errorClass``` => Error class for .form-group div. Defaults to 'has-error'.
52+
- ```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.
53+
- ```feedback``` => allows feedback icons in text inputs, passing ```fa-icon-name``` or ```glyphicon-icon-name``` will render the full ```<i>``` tag.
54+
- ```inputGroup``` => array options that supports the following params:
55+
- ```size``` => can be ```sm``` or ```lg```
56+
- ```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.
57+
- ```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.
58+
- ```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.
59+
- ```checkboxLabel```: if set, will wrap a single checkbox inside a ```div.checkbox``` and a ```label``` with the passed text.
60+
- ```inline``` => used in conjuntion with checkbox and radio groups to allow inline display.
61+
62+
63+
## Global form styles
64+
65+
Global form styles can be defined in bootstrap.php and used anywhere by passing the ```formStyle``` option in create() method.
66+
67+
Inbuilt styles horizontal and inline included are defined like:
1368

14-
---
15-
#### Version 1.1 in progress, will be released soon
16-
---
69+
```php
70+
Configure::write('Bs3.Form.styles', array(
71+
'horizontal' => array(
72+
'formDefaults' => array(
73+
'submitDiv' => 'col-sm-10 col-sm-offset-2'
74+
),
75+
'inputDefaults' => array(
76+
'label' => array(
77+
'class' => 'col-sm-2 control-label'
78+
),
79+
'wrap' => 'col-sm-10',
80+
)
81+
),
82+
'inline' => array(
83+
'inputDefaults' => array(
84+
'label' => array(
85+
'class' => 'sr-only'
86+
),
87+
)
88+
)
89+
));
90+
```
1791

18-
## How to use
92+
## Html helper usage options
1993

20-
Usage instructions and extensive examples can be found at http://bs3form.codaxis.com
94+
TODO
2195

2296
## License
2397

Test/Case/AllTestsTest.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
<?php
22
/**
3+
* AllTestsTest file
4+
*
35
* Licensed under The MIT License
46
* For full copyright and license information, please see the LICENSE.txt
5-
* Redistributions of files must retain the above copyright notice.
7+
* Redistributions of files must retain the above copyright notice
68
*
7-
* @copyright Copyright (c) Codaxis (http://codaxis.com)
8-
* @author augusto-cdxs (https://github.com/augusto-cdxs/
9-
* @link https://github.com/Codaxis/parsley-helper ParsleyHelper
10-
* @package ParsleyHelper.Test.Case
9+
* @author Codaxis (https://github.com/Codaxis/
10+
* @link https://github.com/Codaxis/cakephp-bootstrap3-helpers
1111
* @license http://www.opensource.org/licenses/mit-license.php MIT License
1212
*/
1313

1414
/**
1515
* AllTestsTest class
16-
*
17-
* This test group will run ParsleyFormHelperTest and ParsleyFormTraitTest only
18-
* if version greather than 5.4.
19-
*
20-
* @package ParsleyHelper.Test.Case
2116
*/
2217
class AllTestsTest extends PHPUnit_Framework_TestSuite {
2318

@@ -32,4 +27,4 @@ public static function suite() {
3227
$suite->addTestDirectory($path);
3328
return $suite;
3429
}
35-
}
30+
}

0 commit comments

Comments
 (0)