You are here

function multiselect_fix_selected in Multiselect 5.2

Alters the preview form to include the newly added items

1 string reference to 'multiselect_fix_selected'
multiselect_widget in ./multiselect.module
Implementation of hook_widget @todo Doesn't seem to populate list when in 'preview' (see http://drupal.org/node/139595)

File

./multiselect.module, line 211
Allows users to select multiple items in an easier way than the normal node-reference widget

Code

function multiselect_fix_selected($field, $edit) {
  if (isset($field['#post']) && !empty($field['#post'])) {
    $field_id = $field['selected']['#attributes']['id'];
    $selected = $field['selected']['#post'][$field_id]['selected'];
    $field['selected']['#options'] = array();
    $field['unselected']['#options'] = $field['#all_options'];
    if (!is_null($selected)) {
      foreach ($selected as $selected_nid) {
        $field['selected']['#options'][$selected_nid] = $field['#all_options'][$selected_nid];
        unset($field['unselected']['#options'][$selected_nid]);
      }
    }
  }
  return $field;
}