You are here

function _value_is_disabled_options_state in Value is 7

Helper to save unchangeable checkboxes state and alter $element.

2 calls to _value_is_disabled_options_state()
_value_is_disabled_options_process in ./value_is.module
Process callback for checkboxes elements.
_value_is_disabled_options_value_callback in ./value_is.module
Value callback for checkboxes elements.

File

./value_is.module, line 112
All the element validators for #element_validate.

Code

function _value_is_disabled_options_state(&$element) {
  $passthrough = _value_is_disabled_options_passthrough($element);
  if ($passthrough) {
    return array();
  }
  $state = array();
  foreach ($element['#options'] as $key => $label) {
    if (isset($element['#disabled_options']) && in_array($key, $element['#disabled_options'])) {
      $element[$key]['#disabled'] = TRUE;
      $value = in_array($key, $element['#default_value']) ? $key : 0;
      $state[$key] = $value;
    }
    if (isset($element['#hidden_options']) && in_array($key, $element['#hidden_options'])) {
      $element[$key]['#access'] = FALSE;
      $value = in_array($key, $element['#default_value']) ? $key : 0;
      $state[$key] = $value;
    }
  }
  return $state;
}