/** * Finds the value of this element from userland (in {@link _request}) and returns it * @return mixed array, integer, or string if available, otherwise NULL if no value from userland */ function grab_value() { $value = parent::grab_value(); if ($this->_array_val_ok() && !empty($this->disabled_options)) { $val_array = is_array($this->value) ? $this->value : array($this->value); if ($disabled_selected = array_intersect($this->disabled_options, $val_array, array_keys($this->options))) { if (is_array($value)) { $value = array_merge($value, $disabled_selected); } elseif (!is_null($value)) { $value = array_merge(array($value), $disabled_selected); } else { $value = $disabled_selected; } } } if ($this->_array_val_ok() && is_array($value)) { foreach ($value as $k => $v) { if (!$this->_validate_submitted_value($v)) { unset($value[$k]); } } return $value; } elseif ($this->_string_val_ok() && $this->_validate_submitted_value($value)) { return $value; } return NULL; }
/** * Finds the value of this element from userland (in {@link _request}) and returns it * @return mixed array, integer, or string if available, otherwise NULL if no value from userland */ function grab_value() { $value = parent::grab_value(); /* We can detect that the Other field has content for us if: 1. $value['__other__'] is set (radio groups) 2. '__other__' is an array value in $value (checkbox groups) 3. $value = '__other__' */ if ($this->add_other && (is_array($value) && (isset($value['__other__']) || array_search('__other__', $value)) || $value == '__other__')) { $http_vars = $this->get_request(); if (!empty($http_vars[$this->name . '_other'])) { $other_value = trim($http_vars[$this->name . '_other']); if ($this->_array_val_ok() && is_array($value)) { $value[$this->name . '_other'] = $other_value; if (isset($value['__other__'])) { unset($value['__other__']); } else { if ($key = array_search('__other__', $value)) { unset($value[$key]); } } } elseif ($this->_string_val_ok()) { $value = $other_value; } elseif (!$this->_string_val_ok() && $this->_array_val_ok()) { $value = array($other_value); } } } if ($this->_array_val_ok() && !empty($this->disabled_options)) { $val_array = is_array($this->value) ? $this->value : array($this->value); if ($disabled_selected = array_intersect($this->disabled_options, $val_array, array_keys($this->options))) { if (is_array($value)) { $value = array_merge($value, $disabled_selected); } elseif (!is_null($value)) { $value = array_merge(array($value), $disabled_selected); } else { $value = $disabled_selected; } } } if ($this->_array_val_ok() && is_array($value)) { foreach ($value as $k => $v) { if (!$this->_validate_submitted_value($v)) { unset($value[$k]); } } return $value; } elseif ($this->_string_val_ok() && $this->_validate_submitted_value($value)) { return $value; } return NULL; }