Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/1.1.4'

  • Loading branch information...
commit ed3d6cef448f5843101685812e146bd65bd2f039 2 parents 01165a5 + f86e96d
@slywalker authored
Showing with 43 additions and 40 deletions.
  1. +1 −1  README.md
  2. +42 −39 View/Helper/BootstrapFormHelper.php
View
2  README.md
@@ -7,7 +7,7 @@ About Bootstrap, from Twitter
[twitter/bootstrap - GitHub](https://github.com/twitter/bootstrap)
-This v1.1.3 supports Bootstrap v2.0.2
+This v1.1.4 supports Bootstrap v2.0.2
How to install
--------------
View
81 View/Helper/BootstrapFormHelper.php
@@ -72,7 +72,7 @@ public function checkbox($fieldName, $options, $before = false) {
$options['_div'] = $this->_extractOption('div', $options);
$options['_label'] = $this->_extractOption('label', $options);
$options['_after'] = $this->_extractOption('after', $options);
- if (false === $options['div']) {
+ if (false === $options['_div']) {
$options['label'] = false;
} else {
$options['after'] = null;
@@ -92,9 +92,14 @@ public function checkbox($fieldName, $options, $before = false) {
unset($options['_label']);
unset($options['_div']);
+ if (!is_array($label)) {
+ $label = array('text' => $label);
+ }
$label = $this->addClass($label, 'checkbox');
- $out = parent::checkbox($fieldName, $options) . $label['text'];
- return $this->label($fieldName, $out, array('class' => $label['class']));
+ $text = $label['text'];
+ unset($label['text']);
+ $out = parent::checkbox($fieldName, $options) . $text;
+ return $this->label($fieldName, $out, $label);
}
}
@@ -159,14 +164,9 @@ public function submit($caption = null, $options = array()) {
'div' => 'form-actions',
);
$options = Set::merge($default, $options);
- $div = $options['div'];
- unset($options['div']);
-
+ $div = $this->_extractOption('div', $options);
$out = $this->button($caption, $options);
- if ($div) {
- $out = $this->Html->div($div, $out);
- }
- return $out;
+ return (false === $div) ? $out : $this->Html->div($div, $out);
}
public function input($fieldName, $options = array()) {
@@ -179,15 +179,6 @@ public function input($fieldName, $options = array()) {
$type = $this->_extractOption('type', $options);
$options = $this->_getType($options);
- $options['label'] = $this->_extractOption('label', $options);
- if (false !== $options['label'] && !is_array($options['label'])) {
- $options['label'] = array('text' => $options['label'], 'class' => null);
- }
- $options['div'] = $this->_extractOption('div', $options);
- if (false !== $options['label'] && false !== $options['div']) {
- $options['label'] = $this->addClass($options['label'], 'control-label');
- }
-
$options = $this->uneditable($fieldName, $options, true);
$options = $this->addon($fieldName, $options, true);
$options = $this->textarea($fieldName, $options, true);
@@ -195,16 +186,6 @@ public function input($fieldName, $options = array()) {
$options = $this->_controlGroupStates($fieldName, $options);
$options = $this->_buildAfter($options);
- $disabled = $this->_extractOption('disabled', $options, false);
- if ($disabled) {
- $options = $this->addClass($options, 'disabled');
- }
-
- $div = $this->_extractOption('div', $options);
- $options['div'] = false;
- $label = $this->_extractOption('label', $options);
- $options['label'] = false;
-
$hidden = $this->_hidden($fieldName, $options);
if ($hidden) {
$options['hiddenField'] = false;
@@ -213,20 +194,42 @@ public function input($fieldName, $options = array()) {
if (is_null($type)) {
unset($options['type']);
}
- $out = parent::input($fieldName, $options);
- if ($div) {
- $out = $this->Html->div('controls', $out);
+ $disabled = $this->_extractOption('disabled', $options, false);
+ if ($disabled) {
+ $options = $this->addClass($options, 'disabled');
}
- $out = $hidden . $out;
+ $div = $this->_extractOption('div', $options);
+ $options['div'] = false;
+
+ $before = $this->_extractOption('before', $options);
+ $options['before'] = null;
+
+ $label = $this->_extractOption('label', $options);
if (false !== $label) {
- $out = $this->label($fieldName, $label['text'], array('class' => $label['class'])) . $out;
- }
- if ($div) {
- $out = $this->Html->div($div, $out);
+ if (!is_array($label)) {
+ $label = array('text' => $label);
+ }
+ if (false !== $div) {
+ $class = $this->_extractOption('class', $label, 'control-label');
+ $label = $this->addClass($label, $class);
+ }
+ $text = $label['text'];
+ unset($label['text']);
+ $label = $this->label($fieldName, $text, $label);
}
- return $out;
+ $options['label'] = false;
+
+ $between = $this->_extractOption('between', $options);
+ $options['between'] = null;
+
+ $input = parent::input($fieldName, $options);
+ $divControls = $this->_extractOption('divControls', $options, 'controls');
+ $input = $hidden . ((false === $div) ? $input : $this->Html->div($divControls, $input));
+
+ $out = $before . $label . $between . $input;
+ return (false === $div) ? $out : $this->Html->div($div, $out);
}
protected function _getType($options) {
@@ -301,7 +304,7 @@ protected function _buildAfter($options) {
}
protected function _controlGroupStates($fieldName, $options) {
- if (false !== $options['div']) {
+ if (false !== $this->_extractOption('div', $options)) {
$inlines = (array) $this->_extractOption('helpInline', $options, array());
foreach ($options as $key => $value) {
if (in_array($key, array('warning', 'success'))) {
Please sign in to comment.
Something went wrong with that request. Please try again.