You are here

function blockreference_select_sort_process in Block reference 7

Same name and namespace in other branches
  1. 6 blockreference.module \blockreference_select_sort_process()

Process callback for a blockreference_select_sort element.

See also

blockreference_element_info().

1 string reference to 'blockreference_select_sort_process'
blockreference_element_info in ./blockreference.module
Implements hook_element_info().

File

./blockreference.module, line 892
Defines a field type for referencing a block from a node.

Code

function blockreference_select_sort_process($element, $form_state, $form) {
  if (user_access('administer modules')) {
    drupal_set_message(t('Block reference select lists (with drag-and-drop sort) are deprecated.  Please use the <a href="!field_collection">Field collection</a> module.', array(
      '!field_collection' => 'http://www.drupal.org/project/field_collection',
    )), 'error', FALSE);
  }
  $field_name = $element['#parents'][0];
  $language = $element['#parents'][1];
  $field = $form_state['field'][$field_name];
  $instance = $field[$language]['instance'];
  $current_bid = isset($element['#value'][$element['#columns'][0]]) ? $element['#value'][$element['#columns'][0]] : '';
  $element[$element['#columns'][0]] = array(
    '#type' => 'select',
    '#options' => blockreference_list_values($field, $language, $current_bid),
    '#multiple' => 0,
    '#default_value' => $current_bid,
    '#delta' => $element['#delta'],
    '#columns' => $element['#columns'],
    '#title' => $instance['label'],
    '#required' => $element['#required'],
    '#description' => isset($element['#description']) ? $element['#description'] : '',
  );
  return $element;
}