Field should behave like taxonomy-term reference field.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

Status: Active » Needs review
FileSize
1.93 KB

Extend term's getReferencableEntities()

amitaibu’s picture

FileSize
18.83 KB

er-term.jpg

amitaibu’s picture

Patch supports OptGroups in case of multiple bundles.
optgroup.jpg

amitaibu’s picture

Title: Widget should allow showing taxonomy terms hierarchy » Return values from getReferencableEntities() keyed bu bundle
FileSize
12.49 KB
  • This will result with optgroup for all reference, unless there is only a single bundle in the result
  • Uses taxonomy_get_tree() for term reference

Adapted tests.

amitaibu’s picture

Title: Return values from getReferencableEntities() keyed bu bundle » Return values from getReferencableEntities() keyed by bundle
amitaibu’s picture

Status: Needs review » Fixed

Committed.
I have created a change-record -- http://drupal.org/node/1824434

amateescu’s picture

Status: Fixed » Needs review
FileSize
705 bytes
+++ b/entityreference.module
@@ -762,7 +762,12 @@ function entityreference_field_widget_settings_form($field, $instance) {
+  if (count($options) == 1) {
+    $key = key($options);
+    $options = $options[$key];
+  }
+  return $options;

I think here you only want this:

return (count($options) == 1) ? reset($options) : $options;

Patch attached :)

amitaibu’s picture

FileSize
3.71 KB

Patch makes sure getReferencableEntities() return the bundle's machine-name. and hook_options_list() changes that to the label.

amitaibu’s picture

Status: Needs review » Fixed

Committed. Going to re-roll 8.x accordingly.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.