Skip to content
This repository
Browse code

Decompose complex nested conditionals.

Refs #808
  • Loading branch information...
commit e38c149880ea7887e6b862a73827a1d8d43c425e 1 parent a208eb6
Mark Story authored August 02, 2012

Showing 1 changed file with 15 additions and 9 deletions. Show diff stats Hide diff stats

  1. 24  lib/Cake/View/Helper/FormHelper.php
24  lib/Cake/View/Helper/FormHelper.php
@@ -2429,15 +2429,21 @@ protected function _selectOptions($elements = array(), $parents = array(), $show
2429 2429
 
2430 2430
 					if ($attributes['style'] === 'checkbox') {
2431 2431
 						$htmlOptions['value'] = $name;
2432  
-						
2433  
-						if (!empty($attributes['disabled'])) {
2434  
-							if (is_array($attributes['disabled'])) {
2435  
-								if (in_array($htmlOptions['value'], $attributes['disabled'])) {
2436  
-									$htmlOptions['disabled'] = 'disabled';
2437  
-								}
2438  
-							} else {
2439  
-								$htmlOptions['disabled'] = $attributes['disabled'] === true ? 'disabled' : $attributes['disabled'];
2440  
-							}
  2432
+
  2433
+						$disabledType = null;
  2434
+						$hasDisabled = !empty($attributes['disabled']);
  2435
+						if ($hasDisabled) {
  2436
+							$disabledType = gettype($attributes['disabled']);
  2437
+						}
  2438
+						if (
  2439
+							$hasDisabled &&
  2440
+							$disabledType === 'array' &&
  2441
+							in_array($htmlOptions['value'], $attributes['disabled'])
  2442
+						) {
  2443
+							$htmlOptions['disabled'] = 'disabled';
  2444
+						}
  2445
+						if ($hasDisabled && $disabledType !== 'array') {
  2446
+							$htmlOptions['disabled'] = $attributes['disabled'] === true ? 'disabled' : $attributes['disabled'];
2441 2447
 						}
2442 2448
 
2443 2449
 						$tagName = $attributes['id'] . Inflector::camelize(Inflector::slug($name));

0 notes on commit e38c149

Please sign in to comment.
Something went wrong with that request. Please try again.