Skip to content

Commit

Permalink
Merge branch 'release/1.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
slywalker committed Mar 21, 2012
2 parents 01165a5 + f86e96d commit ed3d6ce
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ About Bootstrap, from Twitter


[twitter/bootstrap - GitHub](https://github.com/twitter/bootstrap) [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 How to install
-------------- --------------
Expand Down
81 changes: 42 additions & 39 deletions View/Helper/BootstrapFormHelper.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function checkbox($fieldName, $options, $before = false) {
$options['_div'] = $this->_extractOption('div', $options); $options['_div'] = $this->_extractOption('div', $options);
$options['_label'] = $this->_extractOption('label', $options); $options['_label'] = $this->_extractOption('label', $options);
$options['_after'] = $this->_extractOption('after', $options); $options['_after'] = $this->_extractOption('after', $options);
if (false === $options['div']) { if (false === $options['_div']) {
$options['label'] = false; $options['label'] = false;
} else { } else {
$options['after'] = null; $options['after'] = null;
Expand All @@ -92,9 +92,14 @@ public function checkbox($fieldName, $options, $before = false) {
unset($options['_label']); unset($options['_label']);
unset($options['_div']); unset($options['_div']);


if (!is_array($label)) {
$label = array('text' => $label);
}
$label = $this->addClass($label, 'checkbox'); $label = $this->addClass($label, 'checkbox');
$out = parent::checkbox($fieldName, $options) . $label['text']; $text = $label['text'];
return $this->label($fieldName, $out, array('class' => $label['class'])); unset($label['text']);
$out = parent::checkbox($fieldName, $options) . $text;
return $this->label($fieldName, $out, $label);
} }
} }


Expand Down Expand Up @@ -159,14 +164,9 @@ public function submit($caption = null, $options = array()) {
'div' => 'form-actions', 'div' => 'form-actions',
); );
$options = Set::merge($default, $options); $options = Set::merge($default, $options);
$div = $options['div']; $div = $this->_extractOption('div', $options);
unset($options['div']);

$out = $this->button($caption, $options); $out = $this->button($caption, $options);
if ($div) { return (false === $div) ? $out : $this->Html->div($div, $out);
$out = $this->Html->div($div, $out);
}
return $out;
} }


public function input($fieldName, $options = array()) { public function input($fieldName, $options = array()) {
Expand All @@ -179,32 +179,13 @@ public function input($fieldName, $options = array()) {
$type = $this->_extractOption('type', $options); $type = $this->_extractOption('type', $options);
$options = $this->_getType($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->uneditable($fieldName, $options, true);
$options = $this->addon($fieldName, $options, true); $options = $this->addon($fieldName, $options, true);
$options = $this->textarea($fieldName, $options, true); $options = $this->textarea($fieldName, $options, true);
$options = $this->checkbox($fieldName, $options, true); $options = $this->checkbox($fieldName, $options, true);
$options = $this->_controlGroupStates($fieldName, $options); $options = $this->_controlGroupStates($fieldName, $options);
$options = $this->_buildAfter($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); $hidden = $this->_hidden($fieldName, $options);
if ($hidden) { if ($hidden) {
$options['hiddenField'] = false; $options['hiddenField'] = false;
Expand All @@ -213,20 +194,42 @@ public function input($fieldName, $options = array()) {
if (is_null($type)) { if (is_null($type)) {
unset($options['type']); unset($options['type']);
} }
$out = parent::input($fieldName, $options);


if ($div) { $disabled = $this->_extractOption('disabled', $options, false);
$out = $this->Html->div('controls', $out); 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) { if (false !== $label) {
$out = $this->label($fieldName, $label['text'], array('class' => $label['class'])) . $out; if (!is_array($label)) {
} $label = array('text' => $label);
if ($div) { }
$out = $this->Html->div($div, $out); 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) { protected function _getType($options) {
Expand Down Expand Up @@ -301,7 +304,7 @@ protected function _buildAfter($options) {
} }


protected function _controlGroupStates($fieldName, $options) { protected function _controlGroupStates($fieldName, $options) {
if (false !== $options['div']) { if (false !== $this->_extractOption('div', $options)) {
$inlines = (array) $this->_extractOption('helpInline', $options, array()); $inlines = (array) $this->_extractOption('helpInline', $options, array());
foreach ($options as $key => $value) { foreach ($options as $key => $value) {
if (in_array($key, array('warning', 'success'))) { if (in_array($key, array('warning', 'success'))) {
Expand Down

0 comments on commit ed3d6ce

Please sign in to comment.