Skip to content
Permalink
Browse files

Decompose complex nested conditionals.

Refs #808
  • Loading branch information...
markstory committed Aug 3, 2012
1 parent a208eb6 commit e38c149880ea7887e6b862a73827a1d8d43c425e
Showing with 15 additions and 9 deletions.
  1. +15 −9 lib/Cake/View/Helper/FormHelper.php
@@ -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));

0 comments on commit e38c149

Please sign in to comment.
You can’t perform that action at this time.