You are here

function _select2widget_options_get_options in Select2 Field Widget 7.2

Same name and namespace in other branches
  1. 7 select2widget.module \_select2widget_options_get_options()

Collects the options for a field.

1 call to _select2widget_options_get_options()
select2widget_field_widget_form in ./select2widget.module
Implements hook_field_widget_form().

File

./select2widget.reference.inc, line 111

Code

function _select2widget_options_get_options($field, $instance, $properties, $entity_type, $entity) {

  // Get the list of options.
  $options = (array) module_invoke($field['module'], 'options_list', $field, $instance, $entity_type, $entity);

  // Sanitize the options.
  _options_prepare_options($options, $properties);
  if (!$properties['optgroups']) {
    $options = options_array_flatten($options);
  }
  if ($properties['empty_option']) {
    $label = theme('select2widget_options_none', array(
      'instance' => $instance,
      'option' => $properties['empty_option'],
    ));
    $options = array(
      '_none' => $label,
    ) + $options;
  }
  return $options;
}