Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'd like to be able to utilize some of the configuration available to on term reference fields on entity reference fields when a taxonomy is referenced such as "Force the user to choose a term from a deepest level"
Comments
Comment #2
stefan.r CreditAttribution: stefan.r commentedEntity reference support is currently very rudimentary, we welcome any patches that improve upon it!
Comment #3
dkhalabuda CreditAttribution: dkhalabuda as a volunteer commentedThis issue has been fixed. I copied over the .module file for term reference (hs_taxonomy) to entity reference (hser) and updated the way vocabularies are retrieved and set to utilize entity reference.
Comment #4
manningpete CreditAttribution: manningpete as a volunteer and commentedThat patch creates an error when trying to apply via Simplytest.me.
Comment #5
manningpete CreditAttribution: manningpete as a volunteer and commentedI'm uploading Dmitry's reroll to see it applies via simplytest.me
Comment #6
manningpete CreditAttribution: manningpete at American Medical Association commentedIt does apply, and does what it says it does (provides configuration to either require deepest level of taxonomy, or select any level of taxonomy). Changing to Needs Review.
Comment #7
josephdpurcell CreditAttribution: josephdpurcell at Digital Bridge Solutions for American Medical Association commentedEDIT: after talking with Dmitry I realize almost all this code is copy and pasted. Hence, I'm removing my comments about code quality since that is out of scope--if the code style fixes are fixed here they should also be fixed elsewhere.
Comment #8
josephdpurcell CreditAttribution: josephdpurcell at Digital Bridge Solutions for American Medical Association commentedConfirmed works:
Issues:
It may be that these issues existed previously, in which case perhaps we create a separate ticket to address these issues. If they didn't pre-exist, we should fix them now.
So, next step: verify they didn't exist previously.
Comment #9
josephdpurcell CreditAttribution: josephdpurcell at Digital Bridge Solutions for American Medical Association commentedI think the state of functionality is acceptable.
Comment #10
stefan.r CreditAttribution: stefan.r commentedSo, RTBC?
Comment #11
josephdpurcell CreditAttribution: josephdpurcell at Digital Bridge Solutions for American Medical Association commentedLooking at the code, here is the phpcpd output with the patch applied:
Here is some commentary on each:
In summary, there are some easy wins like 3.7, but overall I don't know that this much refactoring is within scope of this ticket.
Comment #12
josephdpurcell CreditAttribution: josephdpurcell at Digital Bridge Solutions for American Medical Association commentedI'm going to mark this as RTBC with the expectation that we can address the pre-existing functionality issues in #8 and the code duplication in #11 in a separate ticket.
Comment #13
Melissamcewen CreditAttribution: Melissamcewen as a volunteer commentedUnfortunately it breaks features- see attached screenshots
Comment #14
josephdpurcell CreditAttribution: josephdpurcell at Digital Bridge Solutions for American Medical Association commentedBoth errors can be seen here: /admin/structure/features/create
There is a third error that can be seen at: /admin/structure/types/manage/article/fields/field_primary_taxonomy, which is for editing a field instance that is an entity reference targeting taxonomy terms.
And a fourth error that can be seen at: /admin/structure/types/manage/article/fields/field_test2/widget-type, which is for editing a field instance that is an entity reference targeting nodes.
The errors are caused by these lines:
This is the culprit for: Notice: Undefined index: allowed_values in hser_hierarchical_select_config_info() (line 818 of /var/www/docroot/sites/all/modules/contrib/hierarchical_select/modules/hser/hser.module).
This is the culprit for: Notice: Trying to get property of non-object in hser_hierarchical_select_config_info() (line 824 of /var/www/docroot/sites/all/modules/contrib/hierarchical_select/modules/hser/hser.module).
This line the culprit for: Notice: Undefined index: editable in hser_field_widget_form() (line 61 of /var/www/docroot/sites/all/modules/contrib/hierarchical_select/modules/hser/hser.module).
This line the culprit for: Notice: Undefined index: target_bundles in hser_form_field_ui_widget_type_form_alter() (line 167 of /var/www/docroot/sites/all/modules/contrib/hierarchical_select/modules/hser/hser.module).
The common theme is that the widget "settings" property seems to not be getting populated with the correct indexes, e.g. "editable" and "allowed_values". Why that is will require further investigation.
Edit 6/7: Added a fourth error.
Comment #15
dkhalabuda CreditAttribution: dkhalabuda for American Medical Association commentedThis patch fixes the errors by modifying the way vocabularies are retrieved on the configuration page.
Comment #16
josephdpurcell CreditAttribution: josephdpurcell at Digital Bridge Solutions for American Medical Association commentedWhy are only entity references fields that reference taxonomy terms being exported? I would expect any entity reference using hierarchical select to get exported here.
Comment #17
dkhalabuda CreditAttribution: dkhalabuda for American Medical Association commentedUpdated patch. This will now display all entity references on the HS configuration page.
Comment #18
josephdpurcell CreditAttribution: josephdpurcell at Digital Bridge Solutions for American Medical Association commentedLooks good to me and resolves the errors identified in 13 and 14. Setting RTBC.
Comment #20
stefan.r CreditAttribution: stefan.r commentedCommitted, thanks!
Comment #21
Melissamcewen CreditAttribution: Melissamcewen as a volunteer commentedUnfortunately we discovered this patch has issues in our production environment. It prevented users from adding multiple terms even though the field allows it- when multiple terms already existed, it deleted them.
I wouldn't roll this in unless it has associated tests and they pass. Also I noticed some of the basic unit tests already in the module aren't passing even w/o this patch.
Comment #22
manningpete CreditAttribution: manningpete at American Medical Association commentedSteps to reproduce
- Red
-- Crimson
-- Blood
--- Dried
--- Fresh
- Green
- Blue
Comment #23
manningpete CreditAttribution: manningpete at American Medical Association commentedUpon further investigation, the existing multiple terms were not deleted from the database. Unrelated to this patch, many of the nodes themselves had been deleted. Once I updated to hierarchical_select-7.x-3.0-beta7 (without the patch), the existing multiple terms are showing again.
Comment #24
dkhalabuda CreditAttribution: dkhalabuda for American Medical Association commentedThe settings have to be updated to "Enable the Dropbox" in the Widget Type settings: admin/structure/types/manage/$field_type$/fields/$field_name$/widget-type
Please confirm.
Comment #26
m.lebedev CreditAttribution: m.lebedev commentedComment #27
m.lebedev CreditAttribution: m.lebedev commented