|
@@ -2577,17 +2577,7 @@ class FormHelper extends Helper
|
|
|
if ($context->hasError($field)) {
|
|
if ($context->hasError($field)) {
|
|
|
$options = $this->addClass($options, $this->_config['errorClass']);
|
|
$options = $this->addClass($options, $this->_config['errorClass']);
|
|
|
}
|
|
}
|
|
|
- $isDisabled = false;
|
|
|
|
|
- if (isset($options['disabled'])) {
|
|
|
|
|
- $isDisabled = (
|
|
|
|
|
- $options['disabled'] === true ||
|
|
|
|
|
- $options['disabled'] === 'disabled' ||
|
|
|
|
|
- (is_array($options['disabled']) &&
|
|
|
|
|
- !empty($options['options']) &&
|
|
|
|
|
- array_diff($options['options'], $options['disabled']) === []
|
|
|
|
|
- )
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $isDisabled = $this->_isDisabled($options);
|
|
|
if ($isDisabled) {
|
|
if ($isDisabled) {
|
|
|
$options['secure'] = self::SECURE_SKIP;
|
|
$options['secure'] = self::SECURE_SKIP;
|
|
|
}
|
|
}
|
|
@@ -2602,6 +2592,42 @@ class FormHelper extends Helper
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Determine if a field is disabled.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param array $options The option set.
|
|
|
|
|
+ * @return bool Whether or not the field is disabled.
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function _isDisabled(array $options)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!isset($options['disabled'])) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (is_scalar($options['disabled'])) {
|
|
|
|
|
+ return ($options['disabled'] === true || $options['disabled'] === 'disabled');
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isset($options['options'])) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (is_array($options['options'])) {
|
|
|
|
|
+ // Simple list options
|
|
|
|
|
+ $first = $options['options'][array_keys($options['options'])[0]];
|
|
|
|
|
+ if (is_scalar($first)) {
|
|
|
|
|
+ return array_diff($options['options'], $options['disabled']) === [];
|
|
|
|
|
+ }
|
|
|
|
|
+ // Complex option types
|
|
|
|
|
+ if (is_array($first)) {
|
|
|
|
|
+ $disabled = array_filter($options['options'], function ($i) use ($options) {
|
|
|
|
|
+ return in_array($i['value'], $options['disabled']);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return count($disabled) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* Get the field name for use with _secure().
|
|
* Get the field name for use with _secure().
|
|
|
*
|
|
*
|
|
|
* Parses the name attribute to create a dot separated name value for use
|
|
* Parses the name attribute to create a dot separated name value for use
|