Decompose complex nested conditionals.

Refs #808
This commit is contained in:
mark_story 2012-08-02 21:25:27 -04:00
parent a208eb6cb1
commit e38c149880

View file

@ -2429,15 +2429,21 @@ class FormHelper extends AppHelper {
if ($attributes['style'] === 'checkbox') { if ($attributes['style'] === 'checkbox') {
$htmlOptions['value'] = $name; $htmlOptions['value'] = $name;
if (!empty($attributes['disabled'])) { $disabledType = null;
if (is_array($attributes['disabled'])) { $hasDisabled = !empty($attributes['disabled']);
if (in_array($htmlOptions['value'], $attributes['disabled'])) { if ($hasDisabled) {
$htmlOptions['disabled'] = 'disabled'; $disabledType = gettype($attributes['disabled']);
} }
} else { if (
$htmlOptions['disabled'] = $attributes['disabled'] === true ? 'disabled' : $attributes['disabled']; $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)); $tagName = $attributes['id'] . Inflector::camelize(Inflector::slug($name));