You are here

function _select_with_style_get_options_and_attributes in Select with Style 7

Collects the options for a field.

Field may be of type list_* or taxonomy_term_reference.

1 call to _select_with_style_get_options_and_attributes()
select_with_style_field_widget_form in select_with_style/select_with_style.module
Implements hook_field_widget_form().

File

select_with_style/select_with_style.module, line 241
select_with_style.module

Code

function _select_with_style_get_options_and_attributes($field, $instance, $properties) {

  // Get the lists of options and attributes.
  list($options, $option_attributes) = _select_with_style_options_and_attributes_lists($field, $instance['widget']['type'], $instance['widget']['settings']['select_with_style']);

  // Sanitize the options (strip tags from labels, apply XSS filter).
  _options_prepare_options($options, $properties);
  if ($properties['empty_option']) {

    // Trick theme_options_none() into thinking this is for an 'options_select'.
    $instance['widget']['type'] = 'options_select';
    $label = theme('options_none', array(
      'instance' => $instance,
      'option' => $properties['empty_option'],
    ));

    // Prepend _none to the options list.
    $options = array(
      '_none' => $label,
    ) + $options;
  }
  return array(
    $options,
    $option_attributes,
  );
}