http://drupal.org/project/entityreference is popular module that has replaced "Term reference" fields on many installations. Have you considered supporting it?

Comments

stborchert’s picture

Status: Active » Postponed

Have you considered supporting it?

Nope, not yet.
And I doubt this will happen unless some writes a patch for it or one of our customer projects forces me to integrate it since I'm quite busy at the moment. :/

henrijs.seso’s picture

I see, I will probably supply patch then.

henrijs.seso’s picture

Status: Postponed » Needs review
StatusFileSize
new3.62 KB

Good news everyone! Here is patch that enables Entity reference support in for field widgets. As it turns out it was not that hard. There are just two differences between Taxonomy and Entity reference.

  1. Column key is different.
  2. Dictionary machine name is stored in different place in config array.

First problem was fixed by making SHS little more agnostic, we take column key from field data, that means module will use tid for Taxonomy module and target_id for Entity reference. Second problem needed simple logic in finding vocabulary name, so basically four lines needed to be adjusted for compatibility. That's pretty much it for now. I will look into field formatters later, but this can be commited as field formatters and views support does not really depend on these changes and changes are backwards compatible.

henrijs.seso’s picture

Small change in patch. This will apply cleanly if you first apply patch from #1968308: SHS does not work in field collections, posible other side effects.

kaizerking’s picture

how do we use this?
i have content types
1, 2, 3
2 is referenced in 3
1 is referenced in 2
1
1-2
1-2-3
now i want to create a exposed filter view to deepest level that is 3
i want use this in side a field collection which is shopping cart line item. the above content types are hierarchical categories of product

henrijs.seso’s picture

@kaizerking Only taxonomy terms in hierarchical vocabularies are supported by this module.

kaizerking’s picture

oh.ok, then the issue title misrepresents the issues here or am i missing some thing?
entity reference -taxonomy terms would be a better title

stborchert’s picture

Well, that wasn't as easy as it seemed to be.

I've applied the changes from mansspams and added some more magic to reduce the possible target types to terms only. Otherwise users would try to select nodes or something else (as kaizerking did) which doesn't work.
One additional problem I couldn't solve: while you may select multiple vocabularies as source for the field it is not possible at the moment to use this feature in Simple hierarchical select. Only terms of the first selected vocabulary are displayed as options. I did not know yet how to implement this because this would require a rewrite of many functions and structures (especially function shs_term_get_children()).

So for now we stick with one vocabulary only.

kaizerking’s picture

How about other entities:)
build hierarchies with the help of some contrib mod ....and.. apply shs.. looks very long process.but nothing is impossible when you really try.hierarchical select was pain until the SHS:).
keeping this here for future reference.http://drupal.org/node/1540868

henrijs.seso’s picture

@stBorchert Thumbs up. One vocabulary will do for now.

@kaizerking That would be out of current module scope I guess.

stborchert’s picture

I guess I've found a solution for the "multi-vocabulary" problem. Will try and report if it worked.

And yes, using other entity types as taxonomy terms is totally out of scope for Simple hierarchical select. This will not be part of this module.

stborchert’s picture

Phew, I finally managed to solve nearly all the problems with entityreference. Using option "multiple values" for views filters is a littly tipsy at the moment (the filter itself works but the selected options are not displayed correctly) but this is a minor problem.

oenie’s picture

It seems this patch has reintroduced a previous issue #1949624: The widget always pre-selects first value in vocabulary when it is required field , on the level of the views exposed filter.

henrijs.seso’s picture

Could you compare patch in that issue and this one to narrow down where they conflict? I'm little bussy at the moment.

stborchert’s picture

Issue summary: View changes
Status: Needs review » Closed (fixed)

This has been fixed long time ago.

orkutmuratyilmaz’s picture

Do you consider implementing this patch to 7.x-1.7 version?

inno81’s picture

This patch seems to break the behaviour of "Render views filter as select list" in the views settings for non-exposed filters, for entityrefrence fields.
Basically, you don't get to choose the terms with checkboxes, instead you have a plain text field.