Field should behave like taxonomy-term reference field.

Files: 
CommentFileSizeAuthor
#8 1821060_8.patch3.71 KBamitaibu
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1821060_8.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#7 1821060_followup.patch705 bytesamateescu
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1821060_followup.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#4 1821060-er-optgroup-7.patch12.49 KBamitaibu
PASSED: [[SimpleTest]]: [MySQL] 114 pass(es).
[ View ]
#3 1821060-er-term-widget-2.patch2.06 KBamitaibu
PASSED: [[SimpleTest]]: [MySQL] 114 pass(es).
[ View ]
#3 optgroup.jpg6.53 KBamitaibu
#2 er-term.jpg18.83 KBamitaibu
#1 1821060-er-term-widget-1.patch1.93 KBamitaibu
PASSED: [[SimpleTest]]: [MySQL] 114 pass(es).
[ View ]

Comments

amitaibu’s picture

Status:Active» Needs review
StatusFileSize
new1.93 KB
PASSED: [[SimpleTest]]: [MySQL] 114 pass(es).
[ View ]

Extend term's getReferencableEntities()

amitaibu’s picture

StatusFileSize
new18.83 KB

er-term.jpg

amitaibu’s picture

StatusFileSize
new6.53 KB
new2.06 KB
PASSED: [[SimpleTest]]: [MySQL] 114 pass(es).
[ View ]

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
StatusFileSize
new12.49 KB
PASSED: [[SimpleTest]]: [MySQL] 114 pass(es).
[ View ]
  • 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
StatusFileSize
new705 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1821060_followup.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
+++ 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

StatusFileSize
new3.71 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1821060_8.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

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.