Closed (won't fix)
Project:
Entity reference
Version:
7.x-1.0-rc1
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
27 Apr 2012 at 19:27 UTC
Updated:
29 Oct 2012 at 16:12 UTC
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
Comment #1
lsolesen commentedDid you come up with a solution?
Comment #2
rbruhn commented7.x-1.0-rc5 or some earlier release had field setting widget of select list. So I didn't need to do anything custom.
Comment #3
lsolesen commented