I migrated from References to this module and looking for some help in converting the autocomplete to a select field. When creating or editing a node using References, a "contributor" select field was filtered by the OG Group audience field via ajax. For example:

$form['group_audience'][LANGUAGE_NONE]['#multiple'] = 0;
$form['group_audience'][LANGUAGE_NONE]['#ajax'] = array(
    'event' => 'change',
    'callback' => 'bir_contributor_ajax_callback',
    'wrapper' => 'contributor_replace',
);

$gid = null;
if (isset($form_state['values']['group_audience'])) {
  $gid = $form_state['values']['group_audience'][LANGUAGE_NONE][0]['gid'];
} elseif (!empty($node->group_audience[LANGUAGE_NONE][0]['gid'])) {
  $gid = $node->group_audience[LANGUAGE_NONE][0]['gid'];
}

$options = bir_contributor_ajax_options($gid);
$form['contributor'][LANGUAGE_NONE]['#options'] = $options;
$form['contributor'][LANGUAGE_NONE]['#prefix'] = '<div id="contributor_replace">';
$form['contributor'][LANGUAGE_NONE]['#suffix'] = '</div>';
$form['contributor'][LANGUAGE_NONE]['#default_value'] = !is_null($node->uid) ? array($node->uid) : '';

Thus, depending on what group was selected on the node form, the contributor select list would show the available members of that particular group.

I'm looking to have the same functionality using entity reference so I'm obviously going to have to change the field. From looking at the field settings, there does not seem to be a select list option. Any help would be appreciated.

Comments

lsolesen’s picture

Status: Active » Postponed (maintainer needs more info)

Did you come up with a solution?

rbruhn’s picture

7.x-1.0-rc5 or some earlier release had field setting widget of select list. So I didn't need to do anything custom.

lsolesen’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)