Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Decompose complex nested conditionals.

Refs #808
  • Loading branch information...
commit e38c149880ea7887e6b862a73827a1d8d43c425e 1 parent a208eb6
@markstory markstory authored
Showing with 15 additions and 9 deletions.
  1. +15 −9 lib/Cake/View/Helper/FormHelper.php
View
24 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));
Please sign in to comment.
Something went wrong with that request. Please try again.