1 options.element.inc | _form_options_to_text($options, $key_type) |
Logic function for form_options_to_text(). Do not call directly.
See also
File
- core/
modules/ field/ modules/ options/ options.element.inc, line 245 - All logic for options form elements.
Code
function _form_options_to_text($options, $key_type) {
$output = '';
$previous_key = false;
foreach ($options as $key => $value) {
// Convert groups.
if (is_array($value)) {
$output .= '<' . $key . '>' . "\n";
foreach ($value as $subkey => $subvalue) {
$output .= (($key_type == 'mixed' || $key_type == 'numeric' || $key_type == 'custom') ? $subkey . '|' : '') . $subvalue . "\n";
}
$previous_key = $key;
}
// Typical key|value pairs.
else {
// Exit out of any groups.
if (isset($options[$previous_key]) && is_array($options[$previous_key])) {
$output .= "<>\n";
}
// Skip empty rows.
if ($options[$key] !== '') {
if ($key_type == 'mixed' || $key_type == 'numeric' || $key_type == 'custom') {
$output .= $key . '|' . $value . "\n";
}
else {
$output .= $value . "\n";
}
}
$previous_key = $key;
}
}
return $output;
}