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') {
$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));