function _options_storage_to_form

Transforms stored field values into the format the widgets need.

Parameters

$items: An array of stored field values.

$options: The options array.

$column: The field storage column of the field.

$properties: An array containing the properties of the widget.

Return value

An array of values in the format used by widgets.

1 call to _options_storage_to_form()
options_field_widget_form in drupal/core/modules/field/modules/options/options.module
Implements hook_field_widget_form().

File

drupal/core/modules/field/modules/options/options.module, line 716
Defines selection, check box and radio button widgets for text and numeric fields.

Code

function _options_storage_to_form($items, $options, $column, $properties) {
  $items_transposed = options_array_transpose($items);
  $values = isset($items_transposed[$column]) && is_array($items_transposed[$column]) ? $items_transposed[$column] : array();

  // Discard values that are not in the current list of options. Flatten the
  // array if needed.
  if ($properties['optgroups']) {
    $options = options_array_flatten($options);
  }
  $values = array_values(array_intersect($values, array_keys($options)));
  return $values;
}