Skip to content

Commit

Permalink
Decompose complex nested conditionals.
Browse files Browse the repository at this point in the history
Refs #808
  • Loading branch information
markstory committed Aug 3, 2012
1 parent a208eb6 commit e38c149
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -2429,15 +2429,21 @@ protected function _selectOptions($elements = array(), $parents = array(), $show

if ($attributes['style'] === 'checkbox') {
$htmlOptions['value'] = $name;

if (!empty($attributes['disabled'])) {
if (is_array($attributes['disabled'])) {
if (in_array($htmlOptions['value'], $attributes['disabled'])) {
$htmlOptions['disabled'] = 'disabled';
}
} else {
$htmlOptions['disabled'] = $attributes['disabled'] === true ? 'disabled' : $attributes['disabled'];
}

$disabledType = null;
$hasDisabled = !empty($attributes['disabled']);
if ($hasDisabled) {
$disabledType = gettype($attributes['disabled']);
}
if (
$hasDisabled &&
$disabledType === 'array' &&
in_array($htmlOptions['value'], $attributes['disabled'])
) {
$htmlOptions['disabled'] = 'disabled';
}
if ($hasDisabled && $disabledType !== 'array') {
$htmlOptions['disabled'] = $attributes['disabled'] === true ? 'disabled' : $attributes['disabled'];
}

$tagName = $attributes['id'] . Inflector::camelize(Inflector::slug($name));
Expand Down

0 comments on commit e38c149

Please sign in to comment.