Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
It would be nice to have the entity or bundles provided using a view, which is same functionality that node reference and user reference currently have.
I'm using this module with field collection (which works nicely) but I need to filter by logged in user, and I'd also like to use fields other than the title for the select list users see. I'm willing to help patch (rather than hacking with form_alter) if the maintainers want this functionality...
Comment | File | Size | Author |
---|---|---|---|
#239 | 1253776.patch | 30.79 KB | Damien Tournoud |
#235 | reference_field.png | 61.72 KB | TimG1 |
#235 | my_view.png | 90.57 KB | TimG1 |
#227 | Entityreference dev 215 patch | 38.09 KB | grantlucas |
#224 | screenshot.png | 176.22 KB | vgulla |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedThanks for your report. I'm in favor of this. Let's make it happen, patches welcome! :)
Comment #2
kmajzlik CreditAttribution: kmajzlik commentedsubscribing
Comment #3
vasikesubscribe. it could help solving custom needs. ex. #1276280: User by role
Comment #4
chalee CreditAttribution: chalee commented+1 subscribing
Comment #5
KarenS CreditAttribution: KarenS commented+1 This might make it possible to deprecate the http://drupal.org/project/references module.
Comment #6
that0n3guy CreditAttribution: that0n3guy commented+1 for sure
Comment #7
Damien Tournoud CreditAttribution: Damien Tournoud commentedHere is what needs to happen:
$data['table']['entity type']
)EntityReferenceHandler
interface for the Views integration as a plugin inhandler/views.inc
Any takers?
Comment #8
nagiek CreditAttribution: nagiek commented.
Comment #9
kenianbei CreditAttribution: kenianbei commentedI've transferred over the bulk of the code from References module, I'll post the patch once I have time to go through it a little more thoroughly...
Comment #10
kenianbei CreditAttribution: kenianbei commentedQuestion: In entityreference_field_settings_form(), should $form['target_type'] be integrated into the view filter, that is should we be passing entity type to EntityReferenceHandler_views and selecting only reference views that are of target_type?
Comment #11
kmajzlik CreditAttribution: kmajzlik commentedI think it is better to filter them hard instead of thinking about it. If you dont think about it then are impossible values passed to form and you have form errors...
Comment #12
kenianbei CreditAttribution: kenianbei commentedI've almost finished everything mentioned above in #7, I went ahead and kept the same format for the form, essentially you first select target entity, then select filter by bundle or filter by view.
I'm not planning on writing tests however, since I don't have much experience with that. I hope someone else can work on that.
Comment #13
bojanz CreditAttribution: bojanz commented@kenianbei, please post your current code, I'm preparing to spend time to make this happen.
Comment #14
that0n3guy CreditAttribution: that0n3guy commentedsubscribing...
Comment #15
ParisLiakos CreditAttribution: ParisLiakos commentedSubscribing
Comment #16
Itangalo CreditAttribution: Itangalo commented+1
Looking forward to testing and screencasting this feature.
Comment #17
splash112 CreditAttribution: splash112 commentedsubscribing,
Hope to see this feature quickly!
Comment #18
timofey CreditAttribution: timofey commented+1 Subscribing
Comment #19
Dig1 CreditAttribution: Dig1 commentedPerfect, this will make entity selection for this great module much cleaner.
Comment #20
kenianbei CreditAttribution: kenianbei commentedJust to update everyone... I've sent my changes to bojanz and he said he would be committing something soon.
Comment #21
Crell CreditAttribution: Crell commentedGreat news. This is a critical feature, IMO. Can we see a patch so that we can help debug it and push it forward?
Comment #22
sachbearbeiter CreditAttribution: sachbearbeiter commentedsub
Comment #23
Crell CreditAttribution: Crell commentedActually it looks like this functionality has been moved to a new module: http://drupal.org/project/entityreference_view_widget
Should this issue be closed then?
Comment #24
bojanz CreditAttribution: bojanz commented@Crell
It's not the same thing.
The functionality described here is taking results from a View, and putting them in an ordinary widget (select box, for example), like References does.
I got an archive from @kenianbei so I'll try to format that into a patch soon.
Comment #25
xlyz CreditAttribution: xlyz commentedsubscribing
Comment #26
Shadlington CreditAttribution: Shadlington commentedSubbing
Comment #27
bojanz CreditAttribution: bojanz commentedHere's the initial patch. I took the code kenianbei sent me, fixed coding standard issues, and made some other small tweaks, then rolled the patch.
It is hardcoded for nodes and users, so it needs work (get the base field, do an entity load, then call $this->getLabel()...).
Comment #28
kenianbei CreditAttribution: kenianbei commentedOne thing about node reference I don't like is the requirement to display node title in the select or autocomplete. In some entity cases that don't use title, or entities that set a default title (like entityreference), you aren't able to display the information you want.
Perhaps we could include a setting to not use the title in the select options, and have the default set to 'Use entity title' or something similar. That way we could display other information in the select that might be more pertinent to the specific use case.
Comment #29
Crell CreditAttribution: Crell commentedIt would make sense to use the View itself to define what gets displayed. The value of the field would be the entity ID, of course, but what if we allow people to add fields to the reference view, and then the display can have configuration for "OK, how do you want those merged into a single string"? Then you can shove whatever data out of the entity you want into the select/autocomplete.
Comment #30
that0n3guy CreditAttribution: that0n3guy commented@crell, thats how the references views works isn't it? Last time I tested it I though it worked that way.
Comment #31
Crell CreditAttribution: Crell commentedCould be. Honestly I should probably shut up since I've not looked at the patch in #27 yet, but the comment says it just does ->getLabel()... :-)
Comment #32
kenianbei CreditAttribution: kenianbei commentedCurrently node references will always pull the title of the node to use for the select or autocomplete options. There are actually two separate problems:
1) Options always appends title to last field for options display.
2) When using the autocomplete widget, autocomplete will only search the title field for matches, even if you've added other fields to the references view.
These are the two issues I hope we can work out in the current patch.
Comment #33
bojanz CreditAttribution: bojanz commentedMy ideas is this: we only take the id from the view. Don't add the title, don't care about the title.
The entity needs to be loaded for access reasons anyway, so we then just take the label it has declared ($this->getLabel()).
Sure, it is vaguely useful to be able to use another column as the title, but I see it as inconsistent, because in all other places the
entity is and can be referenced we have the label, except here.
Searching on another column is unrelated and might not be a bad idea (type in a sku, get a list of products).
Comment #34
Crell CreditAttribution: Crell commentedI disagree. The label is not always the most useful human-identifier string. Take users, for instance. The label is, I believe, a username. But really, who the hell remembers someone's username on a site that tries to show a themed, useful name for a user? Eg, made out of First and Last name fields. If I show that as the display name for a user, I would want that as the auto-complete, too.
Or if I have nodes that, for various reasons, all have the same title (there are plenty of use cases for that), then I would want to display, say, title and formatted creation date to make it easier to tell which is which. Just showing the nid isn't helpful because really, no one but the admin is paying attention to the nid.
Configurable display values is an important feature.
Comment #35
Damien Tournoud CreditAttribution: Damien Tournoud commentedI agree with using Views for the displayed value too. The way I see it, we are using Views for three things here:
Comment #36
xlyz CreditAttribution: xlyz commented+1 for #34
Comment #37
kenianbei CreditAttribution: kenianbei commentedI definitely lean towards #34, #35 as well... I think we should follow reference module's view example in that we require fields as the views row style, and perhaps try to populate it by default with title. Then if the user wants to change it up they can just remove/add fields.
For autocomplete, would it make sense to use view filters to dictate what results are returned?
Comment #38
chalee CreditAttribution: chalee commentedI applied the above patch and I get error message "Invalid display id entityreference_1" when I click the 'add->entity reference ' display. And after this the whole view is no longer accessible.
Comment #39
kenianbei CreditAttribution: kenianbei commented@chalee: Did you try clearing the cache? I had similar problems but I couldn't find exactly what in the code was causing this... clearing the cache worked for me.
Comment #40
chalee CreditAttribution: chalee commentedI tried clearing cache but no change.
Comment #41
blainelang CreditAttribution: blainelang commentedI believe the following use case is related to this issue and am wondering if it has been considered: I have created an Entity with two bundles (Folder and File) using ECK and one of the entity bundles (file) needs to reference the other (folder). I'm able to configure it fine to use entityreference and select the entity type and bundle but the value that displays in the dropdown option is just an ID - the incremental id for the folder entity. The folder bundle has fields like name but there is no way to select that.
Comment #42
Yuri CreditAttribution: Yuri commentedAm I missing something, or is it still not possible to filter a view based on the entity reference field?
I see only target_id and target_type to filter on. Either I am very uninformed, or this issue can be set to major IMO.
Please explain..
Comment #43
michiellucas CreditAttribution: michiellucas commentedsubscribing +1
Comment #44
Itangalo CreditAttribution: Itangalo commentedmicheliellucas: Noooo! Don't +1 and subscribe! Check out the "Follow" button at the top of the issue instead!
Comment #45
michiellucas CreditAttribution: michiellucas commentedoldschool
Comment #46
BootstrapJohnny CreditAttribution: BootstrapJohnny commentedsubscribing +1 on #34 & #35
Comment #47
Fidelix CreditAttribution: Fidelix commented@BootstrapJohnny, there is no need to create subscribing comments anymore.
Use the "Follow" button on the top.
Comment #48
BootstrapJohnny CreditAttribution: BootstrapJohnny commentedApologies for the +1/subscribe... So, I'm trying to be useful here, and probably only looking like the newbie I am... I manually applied all the patches from #27, and I'm definitely missing something. Here's my situation:
I have two content types (one a "school," another is a "school closure"... like for snow days). There is a relation "manages" that has endpoints of the user and the school. I'm trying to create dropdown field in the school closure that only shows the school(s) managed by the user creating the closure.
I can make a view that shows the node titles with a relationship to the user. No problem. I CAN'T make the view appear in the entityreference field. It gives the error: "No eligible view found." I figure it must be the wrong type of view, so I create one that shows entity references selecting "manages" from the "is one of" option, but still there is "no eligible view found."
I'm missing something? What do I not get? Any help or explanation would be appreciated. I know this module is the future of relationships, so I'll do everything I can to help test... I'm just not a coder (yet).
Comment #49
kenianbei CreditAttribution: kenianbei commentedMake sure you have created an "entity reference" display. For example, if you want a list of nodes, create a node (content) view, then add a "Entity Reference" display.
Also make sure that the target type of the field you create is the same type of view you made, User, Node, Taxonomy, etc..
Also note that you may have to clear the cache if you get a "Invalid display id" error message. I've gotten that message on vanilla installs, but on quite complicated sites everything has worked fine.
Comment #50
kenianbei CreditAttribution: kenianbei commentedBTW, I'm hoping to get time this weekend to work on this... I'd really like to have exposed filters show up when selecting the entity. Not sure how to go about this, any ideas?
Comment #51
bojanz CreditAttribution: bojanz commented@kenianbei
For exposed filters you want Entityreference view widget.
Comment #52
kenianbei CreditAttribution: kenianbei commentedAwesome... we should put that one the project page.
Comment #53
kenianbei CreditAttribution: kenianbei commented@bojanz
Is this view widget essentially doing the same thing this patch intended?
Comment #54
bojanz CreditAttribution: bojanz commentedNo. The point of this patch is to provide a way to get a list of results from a view, then stick those results in an ordinary widget.
The linked module creates a widget out of a view.
Comment #55
BootstrapJohnny CreditAttribution: BootstrapJohnny commented@kenianbei
Sweet! Thank you... that worked up to the point that I create the closure. At the top it gives the error in the pink box:
...followed by the debug:
Both of these stay when I remove the sort by content type, and change pager to display all items, though the specifics drop off the bottom of the debug.
Under the "Who is closed" field dropdown I created for the closure content type (Entityreference, select list, target:node entity_managed_by_user node view, Fields: Node: Title) the options shows only "- none -" or "CONTAINS" when there are three sample nodes that appear in the views preview.
I hope this info is helpful..... a bit too much like Greek to me... :P Now I'm stuck again. Let me know if I can test anything, because I'm good at breaking things. ha!
Comment #56
BootstrapJohnny CreditAttribution: BootstrapJohnny commentedAfter beginning to read (attempt to understand) the patch it occurred to me that "Contains" could mean I was using the "wrong" widget, so I switched the field to autocomplete - contains and this had the result of removing the error and the debug. All I'm capable of deducing from this is that there isn't any support for dropdown lists (which is what I happen to need) and perhaps it is only coded for "contains" rather than "starts with" on the autocomplete widget (which will get heavy on server resources for me eventually).
I hope this helps... Cheers!
BootstrapJohnny
Comment #57
sahuni CreditAttribution: sahuni commentedWill there be a new version including that feature soon?
If selection of nodes could be done inside a view, for a new project, I'd choose differently the content type containing the entity reference field.
Comment #58
katbailey CreditAttribution: katbailey commentedHere's a new patch. I've removed quite a bit of code from the original one as there was a ton of cruft in there relating to references module that didn't make any sense in the context of this module (and was causing errors such as those mentioned in #55). I also changed it so that the new handler class extends the base class - purely for the sake of ripping out all of the duplicated method implementations. However given that many of these methods won't even make sense in the new class (as they are EFQ-oriented) it may actually make more sense to trim down the interface (i.e. remove anything EFQ-focused) and make the EntityReferenceHandler_views class just implement the interface instead of extending the base class. THen the base class can be as EFQ-centric as it likes.
The label field for the dropdown is configurable in the view.
I've made it entity-type-agnostic.
I've only done the most rudimentary of testing and this definitely needs more work but wanted to get this up here as people seem anxious to test out a new patch and it would help if I got more input as to what's missing from it.
Comment #59
colanComment #60
Amir Simantov CreditAttribution: Amir Simantov commentedHi guys,
I am not sure, but does this issue discuss the problem I have in this issue: #1353774: Selecting exist nodes referenced by Entity Reference with exposed filter?
Thanks!
Comment #61
Nightwalker3000 CreditAttribution: Nightwalker3000 commentedThanks for your work. Are there any plans when it will be aviable in a stable or dev version? I would also needing this #1276280: User by role feature.
Comment #62
vasikei tried the #58 patch.
i can't make the Entity Reference display, every time it displays the "Preview" form as the display page.
Comment #63
kmajzlik CreditAttribution: kmajzlik commentedmaybe it is related to bug that i found with Node reference: not working with views RC3 , works fine with RC1.
Comment #64
vasikei use the a views dev version newer than RC3
Comment #65
Amir Simantov CreditAttribution: Amir Simantov commentedHi Katherine,
I have applied the patch and cleared caches but the patch do not work for me.
Actually, I do not see any change in the views interface. Where should I look?
I looked in these places:
1. In Filter Criteria for any entity fiield other than target_id (like the legacy "values" approach)
2. In Exposed form style (both with Better Exposed Filters module and without).
Any help will be appreciated. Thanks!
Comment #66
Itangalo CreditAttribution: Itangalo commented@Amir: The change is not in the Views interface, but in the configuration of entity reference fields. (See attached image.)
When applying this patch against dev, it seems Entity Reference is unable to pick up node views I have available on the site. When selecting entity selection mode "Views: Filter by an entity reference view", I get the reply "No eligible view was found". This is despite me having enabled the front page view and the archive view included in Views by default. (Same thing happened when I edited and saved a view, and also when trying the same thing with a comments view.)
This module really rocks. I think it will be one of the most important ones for Drupal 7 site builders.
Comment #67
John Morahan CreditAttribution: John Morahan commentedYou need to add an "Entity reference" display to the view - have you done this?
With this done, it works for me, although the view's preview displays the word "Array" instead of actually previewing anything.
Comment #68
Amir Simantov CreditAttribution: Amir Simantov commented@Itangalo
Thanks for your attention. I was probably wrong understanding what the parch is supposed to do...
What I really want is that INSIDE VIEWS I can use a field of an entity reference as an exposed filter and that the input type will be auto-complete just as for texonomy terms, for example. Attached an image :)
Isn't this patch for my goal? Is there anyway I can achieve this?
Thanks again!
Comment #69
Itangalo CreditAttribution: Itangalo commented@John Morahan: Silly me. A long time ago I knew this, but I had forgotten.
-1-
Now tested, works fine except that I don't get more than one field to show in the field list: Even when adding both title and NID fields in the entity reference view, only the title shows in select lists/autocomplete. (Even using "rewrite fields" in Views doesn't change this.)
This might be a feature, not a bug, but I thought it was still worth reporting.
-2-
Confirming the "array" output in the Views preview.
Comment #70
joelstein CreditAttribution: joelstein commentedI just tried the patch in #58, and I too get a value of "Array" in the Views preview.
Comment #71
haydeniv CreditAttribution: haydeniv commentedNot to bump this but any chance of this getting committed to dev? Patch looks pretty sane. I'm trying to decide whether to redo all of my references to entity references right now in my project and this is a sticking point. I'd just rather not run my project on HEAD if I can help it. Does this need more review?
Comment #72
John Morahan CreditAttribution: John Morahan commentedIt needs someone to fix the "Array" thing, I guess.
Comment #73
cpliakas CreditAttribution: cpliakas commentedA couple of notes on the patch in #58 in addition to the other issues mentioned above...
The first is a hold-over from the References module in that arguments are not accepted even though there is an option in the interface to pass them. The attached patch is a re-roll of #58 that simply passes
$args
to$view->execute_display()
as illustrated in the interdiff. I'm not sure I recommend making the change as-is because introducing arguments causes a whole slew of problems. In addition, wildcards such as %1 are not accepted limiting their usefulness. It might be worth removing the option from the interface and tackling it in a later round of patches.The second issue is minor, but if you toggle between the Simple (with optional filter by bundle) and Views: Filter by an entity reference view options, you get an An illegal choice has been detected. Please contact the site administrator. error. See the screenshot below.
Thanks,
Chris
Comment #74
cpliakas CreditAttribution: cpliakas commentedAttached wrong file as the patch.
Comment #75
IWasBornToWin CreditAttribution: IWasBornToWin commentedJust applied the patch. chose select mode: views. Tired for both target types :taxonomy term and taxonomy vocabulary.
Got a message of "no eligible view was found."
Comment #76
IWasBornToWin CreditAttribution: IWasBornToWin commentedI think I found problem--Apparently we need to go to the view and add an extra display type - Entity Reference? I did this but haven't been able to get my view to show any of the fields....all it shows is one word, "Array"
Comment #77
IWasBornToWin CreditAttribution: IWasBornToWin commentedI continually get this pop up error when trying to create an entity reference view display. See attached screenshot.
Comment #78
kunago CreditAttribution: kunago commentedI have a partial fix for the options' names displayed in the select element. I am not going to post a patch, maybe an update so we can move on with the issue.
When you go to Views and try to set the format (next to Entity reference list), the Title field is always empty. To be able to change the display title for all the options in the select element, you need to change the patched "entityreference_plugin_style.inc" file.
There you need to replace the line
with the line
Then you will be able to change the Title field. The limitation is that you can only choose fields added to the view and also any rewrites for any field are not taken into account. So for example, in case you are trying to prepend the node title with anything by rewriting the field value, only the original field value is displayed.
I have been trying to address the parsing of rewrites but no joy. Views is a way too complicated module for me.
Comment #79
haydeniv CreditAttribution: haydeniv commentedJust to move this forward here is a patch with the change in 78. Plus I wanted to play with git so hopefully this patch works.
Comment #80
tvilms CreditAttribution: tvilms commentedCheers to the people working on closing out this issue. Great work so far! I've applied the patch from #79 and I'm now able to use a reference view to filter nodes when creating entity references. It works, but with one Notice popping up when I save the node.
Notice: Undefined index: target_bundles in EntityReferenceHandler_base->buildEntityFieldQuery() (line 174 of .../sites/all/modules/entityreference/handler/base.inc).
Comment #81
haydeniv CreditAttribution: haydeniv commented@IWasBornToWin I was having the same error. It seems to have something to do with the way taxonomy is being stored. The problem is a node entity uses the field "title" for its primary field name but taxonomy uses the field "name" for its primary field name. Right now this patch does not account for taxonomy's unusual storage structure and will need to be updated to work correctly with taxonomy.
Right now to account for it I'm trying to add around line 39 of views/entityreference_plugin_style.inc
That makes the error go away but I don't know if it gives us the functionality yet.
Comment #82
IWasBornToWin CreditAttribution: IWasBornToWin commented@haydeniv I'm unable to remove the error with your code. I wonder if I am adding it at the wrong line?
I added the last patch which now allows me to choose the view to reference. But I can't edit the node where I'ver inserted the entity reference field. I get the error both when trying to edit the node or click in the entity reference field within views;
when trying to edit node;
error - Fatal error: Call to a member function get_value() on a non-object in .../sites/all/modules/entityreference/views/entityreference_plugin_style.inc on line 59
Comment #83
vasiketest results for a user entityreference, last patch
1. once selected the "Views: Filter by an entity reference view ", the "Simple (with optional filter by bundle)" option for field settings disappears.
2. error in the autocomplete
Comment #84
IWasBornToWin CreditAttribution: IWasBornToWin commentedIn reference to #81. I was inserting code on wrong line. Now I'm able to save the entity reference view type with no error. I'm also able to choose taxonomy terms from that view type, from a node. There are two issues left on my end.
1. The taxonomy parent term doesn't show up as a title in the drop down list. I can do this with all other view types except entity reference. It has a drop down for title field but it wont drop and allow a value. (see screen shot)
2. Even though the field reference is saved in the node, I get these errors each time I save.
Notice: Undefined index: tid in taxonomy_field_is_empty() (line 1395 of .../modules/taxonomy/taxonomy.module).
Notice: Undefined index: target_bundles in EntityReferenceHandler_base->buildEntityFieldQuery() (line 174 of .../sites/all/modules/entityreference/handler/base.inc).
Notice: Undefined index: tid in taxonomy_field_is_empty() (line 1395 of .../modules/taxonomy/taxonomy.module).
Comment #85
RuiMendes CreditAttribution: RuiMendes commentedhi,
to correct this, you should use:
instead of:
--
I'm currently having a problem. I'm using the latest dev version of entity reference and applied the patch #79, but there is no option views in the entity selection mode, on the node edit form.
With an old version the patch works. Anyone has the same problem?
Comment #86
John Morahan CreditAttribution: John Morahan commentedYes a bunch of stuff got moved around, here is a reroll. Also the autocomplete should actually filter stuff in this version.
Not including your change above yet, as I hadn't seen it.
Comment #87
RuiMendes CreditAttribution: RuiMendes commentedPerfect. It worked.
Thanks.
Comment #88
clashar CreditAttribution: clashar commentedcould please someone attach 1 archive file with all files including patched ones. There are 7 files to be patched, and I can do only one by one on my Windows and should also divide the diff file to corresponding 7 parts.
Comment #89
bojanz CreditAttribution: bojanz commented@clashar
Not sure there's any point in testing an incomplete patch if you don't even know how to apply it.
Comment #90
clashar CreditAttribution: clashar commented@bojanz,
I patch with NetBeans IDE, not manually. If you think that patch is incomplete, ok I wouldn't test it yet.
Comment #91
IWasBornToWin CreditAttribution: IWasBornToWin commented@ Rui, #85 code--I cant find the code. Can you tell me which file to replace this code?, $options = $form['grouping'][0]['field']['#options'];
thanks
Comment #92
RuiMendes CreditAttribution: RuiMendes commented@ kunago, #78 code
On file entityreference_plugin_style.inc this you may find
$options = $form['grouping'][0]['field']['#options'];
or this:
$options = $form['grouping']['#options'];
I don't know if the patched #86 has already the change suggested by kunago.
Comment #93
IWasBornToWin CreditAttribution: IWasBornToWin commentedThank you, it did work for allowing me to select a title label in views. But I don't notice any changes anywhere. Still getting "array" in the views list and still not able to show taxonomy parent title in the drop down of the taxonomy list.
Lastly, i'm still getting this error - Notice: Undefined index: target_bundles in EntityReferenceHandler_base->buildEntityFieldQuery() (line 174 of .../sites/all/modules/entityreference/handler/base.inc).
Comment #94
IWasBornToWin CreditAttribution: IWasBornToWin commentedI just installed and updated latest dev version because it had a modification date of today. I assumed it had all of these patches applied. Is my assumption incorrect?
Nothing is working now. I cant access the entity view, nor can i add a new field referencing a taxonomy view. There's not choice to add new entity reference style in views either.
Comment #95
sime@IWasBornToWin this patch has not been committed yet, you'll need to reapply it.
Comment #96
kunago CreditAttribution: kunago commented@ RuiMendes:
The first line you mentioned is the correct one to display the title field and this line is also changed in the latest patch #86. So this should work fine.
Comment #97
IWasBornToWin CreditAttribution: IWasBornToWin commentedIs it possible for someone to upload the latest patched tar file? I have net beans but this i'm out of my element. My patching seems to only partially patch and I've spent a lot of time without successful results.
I installed the dev version but unable to apply all patches from #86. Net beans keeps telling me the patch is partially applied. I even opened each individual file which was changed and applied the patch but still get errors when uploading new files to website.
Thanks
Comment #98
haydeniv CreditAttribution: haydeniv commented@IWasBornToWin patches are not designed to be applied to the latest dev snapshot. They are meant to be applied against the GIT branch. See http://drupal.org/node/1246440/git-instructions/7.x-1.x for instructions on how to get it. You can access that page for any project from the project page and clicking on the Version Control link. So for this project you can click on version control from this page http://drupal.org/project/entityreference and then select 7.x-1.x from the Version to work from drop down. The easiest way to do all that is to use GIT.
Comment #99
IWasBornToWin CreditAttribution: IWasBornToWin commentedI'm sorry but everything you just said was foreign to me. Based on item #95 I thought I needed to apply a patch. I have been changing and applying small patches and code throughout this process, and then I mistakenly downloaded the latest dev version because it was dated most recent. I also mistakenly assumed all these changes would be in the latest dev version since its modified date was later than all of this.
I'm not into development enough to get involved with what you suggested. It would appear that I should be able to download a recent file and apply these changes (latest patch) to get where I need to be...no? This is what #95 seemed to imply.
Comment #100
tim.plunkett#98: Patches can be applied against the latest dev snapshot. And it's Git or git, not GIT.
In this case, the patch doesn't apply even with git. And as #89 says, the patch isn't complete.
Comment #101
IWasBornToWin CreditAttribution: IWasBornToWin commentedI'd love to get my hands on the latest dev tar file with the latest patch applied.
Comment #102
John Morahan CreditAttribution: John Morahan commentedReroll, untested
Comment #103
John Morahan CreditAttribution: John Morahan commentedbtw the patch modifies the .info file which is different in the dev snapshot from what's in git, so if the patch applies to one and not the other, that's probably why
Comment #104
haydeniv CreditAttribution: haydeniv commentedAwesome patch in #102 is working very well now. Just a small problem with errors being thrown during cache flush and update.php. This fixes that although probably not the best way. Just adds
around line 10 of plugins/select/views.inc
Here is a reroll with that change. I tested using a select list and autocomplete field types with a view that has nid as first field and title as the second field in the view. Off to test taxonomy next.
EDIT:
Grr disregard patch need to figure out why it is incomplete.
Comment #105
IWasBornToWin CreditAttribution: IWasBornToWin commentedI also applied the patch and it works great. I didn't have any issues with flushing cache and running update. Testing it on taxonomy term view and works well. Although, I'm not able to duplicate the same view in my autoselect dropdown when creating a new node and adding a taxonomy reference to it.
In the view I have terms sorted by parent(not linked to term) so the view shows;
parent
child(linked)
child(linked)
child(linked)
but the dropdown when adding a node shows;
child
child
child
Comment #106
haydeniv CreditAttribution: haydeniv commentedOk Nodes work great but taxonomy gives me
When trying to add content that has that view as a reference.
Comment #107
IWasBornToWin CreditAttribution: IWasBornToWin commentedThe patch is working excellent for me. I'm using dev version with patch from #102. Also using views version 7.x-3.1-dev
Comment #108
hadsie CreditAttribution: hadsie commentedI'm running the latest copy of dev from git and the patch from #104 but whenever I try to add a entity reference type display I get "Invalid display id entityreference_1". The only way to proceed from that is to completely delete the view and start over. I've tried uninstalling/re-installing, cleared caches several times, etc. Not really sure how to get past or debug this one.
Comment #109
gmak CreditAttribution: gmak commentedI confirm I am getting the same behaviour as mentioned in #108.
Drupal 7.12
Views 7.x-3.1
Entity Reference 7.x-1.x-dev
Comment #110
gmak CreditAttribution: gmak commentedFurther to #109, I am also not seeing the full screen to allow editing of the view. I only get the section that is for previewing (see the attached).
Comment #111
John Morahan CreditAttribution: John Morahan commented#104 is missing some files I think.
Comment #112
tauno CreditAttribution: tauno commentedModified the patch so a sanitized version of fields are rendered in the widget. Also replaced the field title option with a search fields option that lets the admin select one or more fields fields from the view to search when using the autocomplete widget.
Only tested with taxonomy entities and the autocomplete widget so far.
Comment #114
John Morahan CreditAttribution: John Morahan commentedI figured out what was causing the test failures. Also renamed the handler for consistency.
Comment #115
IWasBornToWin CreditAttribution: IWasBornToWin commentedI wasnt able to get the latest patch to work. Patch in #104 has been working for me (except showing taxonomy id in parenthesis when selected ( term(541)).
Do I apply the latest patch to my files after patch from 104 or to a clean dev download? I've actually tried both with no success.
Comment #116
Damien Tournoud CreditAttribution: Damien Tournoud commentedNice to see this taking shape.
Some code review:
Please try to move this to
plugins/selection/EntityReference_SelectionHandler_Views.class.php
.My feeling is that this handler should not extend EntityReference_SelectionHandler_Generic but implement EntityReference_SelectionHandler directly. It would show that there are a couple of methods that are not implemented yet but should be: EntityReference_SelectionHandler::countReferencableEntities(), EntityReference_SelectionHandler::validateReferencableEntities() and EntityReference_SelectionHandler::getLabel().
This should be plural, right? Plus it should have some explanation on how to create a "eligible view".
That doesn't seem to make a lot of sense. The match text should really be passed as a proper argument to the view. We can ignore $match_operator in the view-specific implementation.
Comment #117
IWasBornToWin CreditAttribution: IWasBornToWin commentedis #116 a solution/addition to my issue in #115? or are these suggestions for the module maintainer?
Comment #118
Peter Bex CreditAttribution: Peter Bex commentedI tried the patch but it seems to break something in views (or it could just be a bug in views).
When I click "add" and add a display of the type entity reference, it reloads the page and it only shows the "update preview" button with the arguments input box and the "auto update preview" checkbox. The display settings form is completely gone, so I can't edit the view at all.
When I go back to the view by navigating "structure->views->my view", the entity reference display is actually added, but when I click it again it does the same thing.
update: note that this only happens for these entity reference display types; for page and block types everything's still okay.
update2: If I click "update preview" it says "Invalid display id entityreference_1"
Comment #119
John Morahan CreditAttribution: John Morahan commentedUploading what I've got so far.
Comment #120
samerali CreditAttribution: samerali commented#119: 1253776.patch queued for re-testing.
Comment #121
R.J. Steinert CreditAttribution: R.J. Steinert commented#119 worked for me. I did manage to get an error by doing things in the wrong order though.
1. Apply the patch.
2. Edit an existing field with an entity reference field.
3. Set "Views: Filter by an entity reference view"
4. Displays error that there are no Entity Reference Views Displays to use.
5. Save the field. (Dun Dun Dun Duuuun)
6. Create an Entity Reference Views Display.
7. Go back to the field and edit it, results in the following error.
"Fatal Error: Call to a member function execute_display() in /.../entityreference/plugins/selection/EntityReference_SelectionHandler_Views.class.php on line 109"
Comment #122
retrodans CreditAttribution: retrodans commentedI am having trouble with the autocomplete on that patch aswell, the list widget populates, but autocompletes doesn't ever seem to return anything. Other autocompletes (eg nodereference pulling in all nodes of a certain content type) work fine.
Comment #123
IWasBornToWin CreditAttribution: IWasBornToWin commentedsame here, no autocomplete
Comment #124
IWasBornToWin CreditAttribution: IWasBornToWin commentedno entity reference view available after patch in 119. probably why no autocomplete. If I go to the view, i cant access the entity reference. And if I edit the node field I cant select a view either.
Comment #125
jordisan CreditAttribution: jordisan commentedI guess it's not possible to use dynamic arguments (yet) or contextual filters...
I want to limit the options available depending on the node being edited; concretely, I want the view to show just the nodes belonging to the same organic group that the node being edited.
Do you have any ideas of how to do that?
Thanks
Comment #126
freelockTrying #119 on 1.0-beta4, with a select widget and a view returning user entities, and no dice -- the widget shows up correctly populated from the view, but you can't save because of an "ambiguous field: uid" error from the database.
Tracked this down to views/entityreference_plugin_display.inc, in entityreference_plugin_display->query.
Line 60 in this file adds the field for the id. The problem, if this is referring to a user entity, is that the uid column appears on a bunch of tables, and the column does not get properly aliased with this call.
Attached patch is against code that's in comment #119...
Comment #128
freelock... and if this seems like a reasonable approach, here's the entire patch against -beta4, which will hopefully satisfy the test bot...
Comment #130
freelockFine... this patch is now against 1.x-dev...
Comment #131
vasikeTried last patch (#130) within the dev and for a User entity reference of a Content type (node).
Results
- no errors
- the select widget works
- the autocomplete won't (returns nothing), same as #122, #123
Comment #133
John Morahan CreditAttribution: John Morahan commentedThe reason the autocomplete doesn't seem to work, is that as of #112, there's a "search fields" option in the style settings (with nothing selected by default), which controls which fields are used for the autocomplete. If you select the appropriate field(s) there, the autocomplete works - at least for me.
I guess this was not a great idea, as it seems to be confusing everyone...
Comment #134
tauno CreditAttribution: tauno commented@John Morahan, agreed that it's confusing people. Maybe it should default to having all fields selected and allow users to uncheck fields they do not wish to be searched.
Comment #135
joneiseman CreditAttribution: joneiseman commentedI also have this same problem. I created an entity called "Pace" and I have a View which is used to display a list of Paces (it has one field to display the Pace Name field). Under admin->Structure->"Profile Types", I select "Manage Fields" for the "Main Profile". Then I try to add a new "Entity Reference" field. I want to use the view that I created to display my "Pace" entity but when I select "Views: Filter by an entity reference view" it just says "No eligible views were found".
How do I create a view with an Entity Reference display? I'm not sure if I'm doing something stupid or if this patch isn't working the way it's supposed to.
I created my "Pace Entity" based on the example "Model Entity". Do I need to add something to my "Pace" module where I create the "Pace Entity"?
Comment #136
vasikere-test with @John Morahan directions (from #133) for the autocomplete
- the autocomplete returns results
- the results are only for the main user fields, as name or mail,
i tried for a custom use field and it won't search for it - no results
- the display of the autocomplete it seems to be right (the fields and their settings defined in the view)
Comment #137
tauno CreditAttribution: tauno commented@vasike: What do you mean custom field? A field that's exposed through a relationship or your own custom field type that's attached to the entity your view is for?
Comment #138
vasikein my case i have a custom user field, this means a field of entity which view is for.
ex. a first name and/or last name textfields for the user
Comment #139
vasikeImho, i think decoding HTML for the Entity Reference views should be widget related, the HTML formatting can be used for "Check boxes/radio buttons" widget, including images or using an entity display.
or at least to have a view option to disable the decoding.
Comment #140
sxnc CreditAttribution: sxnc commentedJust used the patch from #130 and it worked fabolous!
Comment #141
Andino CreditAttribution: Andino commentedI'm having the same issues reported in #108-110 and again in #118 patching against dev, D7.12, Views 7.x-3.3. The functionality that this would add is exactly what I need, but, sadly, the select widget shows -none- (I'm guessing because the view itself fails).
I rechecked the code to make sure that the patches applied properly, and that all looks good. Anyone have any good ideas on why the view doesn't properly render?
Comment #142
sjancich CreditAttribution: sjancich commentedI tried the patch in #130, and my autocomplete isn't returning anything. I patched against 7.x-1.x-dev.
If I switch to select list, the entities from my View are there. Not sure why autocomplete isn't pulling them through.
Comment #143
iLLin CreditAttribution: iLLin commentedPatch #130 works pretty good for the most part and applied fine. If you try to re-write a field, nothing shows for that field in the output.
Comment #144
iLLin CreditAttribution: iLLin commentedComment #145
iLLin CreditAttribution: iLLin commentedTo further comment on my last statement is it seems to strip out all HTML markup, so re-write does work just not markup. Is that an option for this view? I have radio buttons that I want a help icon next to and it keeps ripping it out. I have even overwrote the template to try and get it in there as well. Are we looking at a best practice here? Seems limiting in this instance.
Comment #146
iLLin CreditAttribution: iLLin commentedSo line 59 in the entityreference_plugin_style.inc has the strip_tags() function. Taking it out does solve this issue BUT I'm sure we dont want markup in select drop downs or even autocompletes. I haven't messed with views in quite some time so I shouldn't venture on the best approach for this.
Should an option be introduced to allow the user to specify this setting, with it defaulting to stripping out the markup?
Comment #147
tauno CreditAttribution: tauno commentedI think like #139 suggests, stripping the tags should just be for the widgets that can't have HTML.
Comment #148
tim.plunkettI remember making really cool autocompletes in D6 with node reference and Views, like a user name and their profile picture as a thumbnail. Not sure we want to rule that out.
Comment #149
John Pitcairn CreditAttribution: John Pitcairn commented+1 on that Tim...
Comment #150
vasikerework of the #130 patch to allow having html.
still not able to use custom fields as searchable fields for autocomplete widget, but this could be a new "feature request"
Comment #151
vasikereworked the last one for using custom fields for searchable fields
Comment #152
Anonymous (not verified) CreditAttribution: Anonymous commentedI've been silently following this for the past month or so. Thanks everyone who has worked on this. Can't wait til we get this included in the dev version.
Comment #153
hlykos CreditAttribution: hlykos commentedAllowing HTML displays the tags eg.:
<span class="views-field views-field-field-fullname"> <span class="field-content">John Doe</span> </span>
when entity reference is used as an exposed filter in views.Comment #154
rwilson0429 CreditAttribution: rwilson0429 commentedWhen I applied the patch in #151, got the following errors. After applying the patch the sites with entity reference fields crashed.
Comment #155
haydeniv CreditAttribution: haydeniv commented@rwilson0429 it looks like whatever you used to apply the patch changed the read permissions or owner of the files it touched. Check the permissions on these files and make sure the user that runs your web server has access to them.
sites/all/modules/entityreference/entityreference.module
sites/all/modules/entityreference/entityreference.info
Comment #156
grantlucas CreditAttribution: grantlucas commentedI'm having some issues applying the #151 patch. I run "git apply" but get the following errors. Tried git apply --whitespace=fix with no luck.
Anybody have any ideas as to what's going on?
Comment #157
ff1 CreditAttribution: ff1 commented#151: 1253776-151.patch queued for re-testing.
Comment #159
rerooting CreditAttribution: rerooting commentedSo we were up a, er, bad creek without a paddle when we realized that entity reference view widget was going to take a lot of work to do what we needed it to do.
Only a couple of days ago we tried out patch #150, and lo and behold, we can do *nearly* everything we needed to do! We were restricted from using
<div>
elements within the output for obvious reasons, but with a lot of work with custom formatters and the inline fields options we were able to have some wonderful results with option/radio lists.The only things we need to bring into the picture now (for option lists) are:
* Grouping by field
* Dynamically pass contextual filter and ajax refresh an entityreference form field based on the selection.
This was wonderful to find and is very promising!
Here are some examples I thought I would share to illustrate how powerful this single patch is:
Thanks for some awesome work! Glad to help with any more debugging. We will be messing with the muti field autocomplete business and should be providing some help that way. If anyone out there is interested in helping us with the two items above, there is a bounty as our developers either aren't available or up to snuff, especially for item 2. Also, let me know if there is something I'm missing with the field grouping as I notice that the option is exposed. Thanks!
Comment #160
rerooting CreditAttribution: rerooting commentedHey everyone, sorry for the big crazy post - I was really excited. I can take it down if you all need.
I am having trouble getting the views args to pass to the fields - what format should the views arguments be in? Having to use raw URL values currently. Thanks!
Comment #161
grantlucas CreditAttribution: grantlucas commented#150: 1253776-150.patch queued for re-testing.
Comment #162
rerooting CreditAttribution: rerooting commentedNo news on how the views args work with the field settings? I have tried the token format, %1 %2, simple d6 stile user:role, etc. with no luck. I know the entity reference displays work with the contextual filters independently, but as soon as the view is rendered within the field widget there are no results. What am I doing wrong here? Does it just not work yet, or am I missing something?
Comment #163
rerooting CreditAttribution: rerooting commented@iLLin - I've found that certain tags work fine.
<span>, <p>, <img>, <a>,
etc. all work - basically everything that should be ok to show within a label element as it were - I guess these are not stripped using the strip_tags() function. Thats how I got the results below. Also make sure that your row settings are all checked to inline, and that you manually determine the output for each field using the style properties or write custom templates (it think the latter would work but havent tried it). I personally don't need more tags! You could do some disasterous things in one of these if you allowed divs - plus they wouldnt be semantic!! Also, if you need proper line breaks,<p>
will get you quite far!Allowing full HTML would make this really nice and easy for many folks, but would make the markup far less valid very quickly.
Comment #164
that0n3guy CreditAttribution: that0n3guy commented@rerooting, usually when you pass views an argument, you just pass it a number. Have you tried simply passing it nid or uid?
The code doesn't look like it accepts dynamic arguments yet.
p.s. I don't want to derail this issue, but thats pretty sweet what you have there (the images).
Comment #165
rerooting CreditAttribution: rerooting commentedYea I looked into the code and found the same pattern, and thats what I have been doing! Do you mean a number as in 1 or 2, or %1 or %2 as in the argument number? What I am trying to pass, the user roles, is an argument that consists of multiple numbers. My argument works in the views preview for the entity reference display as /3 or /3+2+6, but then I can't get the user roles to work with the views argument in the entity reference field.
I also tried it with nid before for a different problem, but that didnt work either (tried nid Nid node:nid content:nid, etc, etc.). Have you gotten it to work on something as simple as nid or uid yet?
Comment #166
that0n3guy CreditAttribution: that0n3guy commentedNo I mean a number, like 1 or 2. So for the node with nid of 24, you would just put in a number of 24. Like I said, I'm not sure it accepts arguments yet.. though I haven't tested it. Thats just what my quick 2 minute look at the code looked like.
Comment #167
rerooting CreditAttribution: rerooting commented@thaton3guy ah I see. Tried that and it didnt seem to work either. I'll see if one of our devs can take a look at it and submit a patch next week. I've found a workaround for our particular use case that should do the trick for now.
Again, I want to thank everyone who has worked on this patch! A tremendous life saver. I have seen a few comments regarding drupal commerce's product_reference field potentially becoming just an extension that depends on entity reference... and this patch in and of itself is more than enough reason to go this route!
Comment #168
boabjohn CreditAttribution: boabjohn commentedApologies for the side issue, but I've not done a lot of patching in 7.x. Is the git path described up at ca. #98 the only practical option?
Working against the 21 March dev, I dropped the patch at #150 into the entityreference module root (../moduels/entityreference/1253776-150.patch) and ran: patch < 1253776-150.patch
It generally ran well except for a couple of manual "which file should be patched?" notices that I'm not used to, eg:
With the patch applied, caches flushed and db updated, I'm now trying to figure out where the changes appear...ie, there's still only a [Simple] Entity selection mode available. So, not sure if the patch has not applied or if I'm missing some other obvious setting...?
Comment #169
boabjohn CreditAttribution: boabjohn commentedOkay, the progress to date is:
- clean install of the module
- patch applied as described above #168
Now we start a new content type, add a new field of type EntityReference...
But there's no option for [Entity selection mode] other than "Simple"
So, scanning the clues from @john_morahan in #67, we see that first there needs to be a special view display already available. The dsiplay type is not block or page, etc...it is entity reference.
So I started a new, clean view for this purpose.
This view has:
- a single static filter on node type.
- no contextual filters (I want all the nodes of this type)
- one field, the node title.
But (in Views) when I select the display type = Entity Reference, we go straight to a modal overlay that is trying to manage the *preview*, and asks for a contextual filter in order to display a preview (see attached).
We don't seem to get any access to the usual Views config for the display...we're just stuck in a Preview modal and unable to continue.
The only thing to click is the [Update Preview] link, and this returns an error on the display name.
Closing the Preview modal, we can see the EntityReference display has been added to the list of displays in this view...but when we go back to the new content type and try to add an entityreference field from scratch, we still see only the [Simple] selection mode...
Sigh.
Sorry for the long post...hope there's enough detail in here to be useful to you heroic coders who have been working on this (essential in my opinion) bit of functionality.
Thanks in advance for any clues!
Comment #170
rerooting CreditAttribution: rerooting commented@boabjohn are you using the latest dev of both views and entityreference? when applying #150 i did not have these problems
Comment #171
heylookalive CreditAttribution: heylookalive commentedThanks for all the hard work on this patch!
For anyone having trouble applying #150, specifically the view validation issue, the patch file seems to go a bit wrong applying and can scatter files in the wrong places (might be running "patch" wrong?). Take a look at the patch file itself for where things need to go.
Here's an svn status after applying the patch to latest stable:
svn status
? 1253776-150.patch
M entityreference.module
? plugins/selection/views.inc
? plugins/selection/EntityReference_SelectionHandler_Views.class.php
M entityreference.info
? views/entityreference_plugin_style.inc
? views/entityreference_plugin_display.inc
? views/entityreference_plugin_row_fields.inc
M views/entityreference.views.inc
Comment #172
mrfelton CreditAttribution: mrfelton commentedSame problem as described in #161. All I'm getting from Views in relation the the Entity Reference display that I added is as per this screenshot.
EDIT: After updating entityreference from RC1 to latest dev, the view works as expected.
Comment #173
grantlucas CreditAttribution: grantlucas commentedFor those trying to get the 150 patch to apply properly you need to run
git apply -v -p1 1253776-150.patch 2>&1
with the patch filter in the entity reference folder. Also make sure you are on the dev branch. Running git apply instead of patch seems to work better and the part at the far right suppresses the whitespace errors that come up.
After applying this I created a view with a display format of Entity Reference List and all was well.
Only issue right now with patch 150 is that if an item in the select list has an apostrophe, it's html encoded and shows as '
Will take a look at the patch and see if I can resolve this.
Comment #174
rerooting CreditAttribution: rerooting commentedIndeed! Git is being used for patching now in D7, so make sure to use git apply when and where you can.
@grantlucas, can you show me an example of how the views arguments field is supposed to be used?
Comment #175
grantlucas CreditAttribution: grantlucas commentedI've re-rolled the #150 patch with the needed decode_entity() call when generating the list of options from a view.
To test this out, apply the patch to the latest dev branch with
git apply -v -p1 1253776-175.patch 2>&1
And Voila! Results with apostrophes now show their proper apostrophe.
Comment #176
grantlucas CreditAttribution: grantlucas commented@rerooting I can confirm with you that the arguments aren't working like they are supposed to. I will take a look around in the code to see if I can figure out why.
Comment #177
grantlucas CreditAttribution: grantlucas commented@rerooting Alright this is weird. It wasn't working but then after changing nothing, it now works with multiple arguments. I had a view which was based on a contextual filter of uid's. I set the view arguments to "1+2" and it shows me a list of nodes belonging to both users.
Just make sure you have "Allow multiple values" selected in the view. Hope that helps though really i'm stumped as to why it didn't work for me but then did.
Comment #178
rwilson0429 CreditAttribution: rwilson0429 commentedTested patch in #175. Yeah! It works great. Thank you much.
I did encounter problems trying to apply on local machine under Windows 7 using cgywin rxvt-x and git command. Kept getting 'Fatal: git apply: bad git - diff - expected /dev/null on line 39'. Couldn't figure out how to resolve, so I tried applying the patch on a linux server dev site and it applied cleanly.
After applying the patch on the dev server, I copied the entire patched ER folder to the local machine and it worked very well. Wish I knew what I was doing wrong to get the Fatal error. But, in the end, the patch worked very well. Now, it seems less of a need for the entityreference_view_widget module.
This module is awesome. Thank you to all the maintainers and contributors.
Comment #179
grantlucas CreditAttribution: grantlucas commentedAh yeah, the /dev/null thing makes sense.the "2>&1" at the end of that git apply statement suppresses errors to /dev/null which is a Unix only thing so it'll work fine on OSX and Linux but not windows. Glad you got it sorted out though.
Comment #180
rerooting CreditAttribution: rerooting commentedAwesome! Indeed it does work for multiple arguments.
Wondering how folks might feel about extending the patch to handle passing on argument token values (in addition to static values), such as nid or uid, etc (and fixing the single/multi issue if you aren't already on that @grantlucas). If this is beyond the scope of this patch, we can just custom roll it, or we can submit an extended version of the patch if folks are interested. It's up to everyone here!
Comment #181
grantlucas CreditAttribution: grantlucas commentedI would say something like the token addition would be good for a separate patch as this patch is pretty mature so far and does what it originally set out to do. It would be good to get this patch thoroughly tested as is and get it incorporated into the module sooner than later. It would make sense to open a separate issue for token support.
Comment #182
ff1 CreditAttribution: ff1 commentedFantastic!
Using the patch in #175, I now have this working brilliantly. I've created a bunch of entity types and bundles using the ECK module and am able to add references between them using this module. This patch allows me to further limit my entity select list using a view, giving me the sort of functionality I used to have with the d6 userreference and nodereference CCK modules.
I do get the following warning when I apply the patch 'warning: 2 lines add whitespace errors.', so I'm setting this to 'needs review' to let the bot check it. Otherwise, since I agree with both @rerooting and @rwilson0429 that this patch works as advertised, I'd say this is now RTBC.
Thanks for all your hard work!
Comment #183
grantlucas CreditAttribution: grantlucas commented@ff1 Yeah those whitespace errors were in the original patches as well though it doesn't seem to affect the patch overall. Thanks for having it tested! Happy to see it still passes.
I've looked into the white space errors before but I couldn't figure out why it was causing problems. If someone could take a second look and post back that'd be great.
Comment #184
rwilson0429 CreditAttribution: rwilson0429 commentedMy 2 cents @rerooting, that functionality (argument token values) would be very very useful. ER appears to be setting the standard for flexibility, user-friendliness and relating entities. It's already a great module but, making it play well with Views takes it to the top.
Comment #185
ff1 CreditAttribution: ff1 commentedI've rerolled patch from #175 to fix the whitespace errors.
Comment #186
Niremizov CreditAttribution: Niremizov commentedComment #187
IshanComBr CreditAttribution: IshanComBr commentedApplying #185 1253776-185.patch against 7.x-1.x-dev has worked just fine for me
The steps that worked:
- install the "entity reference" dev module
- copy the .patch to the sites/all/modules/entityreference folder;
- execute "$git apply -v -p1 1253776-185.patch 2>&1"
- create/import custom content types and views;
- create/edit a view, add a new display of type "Entity Reference" to it, setting properly the fields you want to be shown;
- on the content type, set a field "entity reference", with "entity selection mode" as "views: filter by an entity reference view" then select the proper "view used to select the entities" option created on previous step (just be sure to NOT selecting "Enable Render Views filters as select list" as this crashes)
Also note it will NOT work for content type fields created before the patch has been applied. One alternative is to use "Features" module to export the content types, apply the patch, import the features exported (just as a regular module) then edit the fields you want to use.
(REF: using views in entity reference select list)
THANK YOU GUYS!!!
Comment #188
rudiedirkx CreditAttribution: rudiedirkx commentedWorks for me too. Only if the set View doesn't exist, the thing crashes **hard**. Some kind of warning and fallback might be nice =)
Comment #189
colanWe need to get that fixed before this can be RTBCed.
Comment #190
ff1 CreditAttribution: ff1 commented@rudiedirkx: Please provide some more details about the crash. What steps did you take to make it crash? Is it repeatable? What errors appear in the server logs?
I'd like to help fix this problem, but can't repeat it.
Comment #191
tim.plunkettI was able to reproduce, and I was also incorrectly allowed to use a disabled view. This takes care of that, and calls watchdog when a view in use by a field is disabled or deleted.
I also reviewed the other code, and I think this is RTBC.
Comment #192
tim.plunkettFixed a php notice and made the watchdog more informative. The interdiff is still against #185.
Comment #193
tim.plunkettSome nitpicks:
This could use an inline comment.
Reverse the conditional so the '' comes last.
Reverse the conditional so the '' comes last.
Missing trailing full stop.
This is a pretty ugly line.
This should come out.
Comment #194
TimG1 CreditAttribution: TimG1 commentedHi All,
I tried patch #193 on -dev (2012-Mar-21). My setup is...
A Job (node type) with a field collection (time_slots) which can have multiple values. Then I have an Interview (node type) with a View Reference field where the View Reference is getting the time_slots field collection values from a Job.
My View returns the correct results in my View Preview. However, when adding a new Interview node my View Reference dropdown shows only the last value from the field collection time_slots values in a Job, not all of the values like in the View Preview.
I tried changing the widget to Autocomplete and I get zero suggestions when typing in the box. I tried changing to checkbox/radio buttons and I get two values...N/A and the last value.
Thanks for reading,
-Tim
Comment #195
rwilson0429 CreditAttribution: rwilson0429 commentedPatch in #192 does not seem to apply correctly.
When I try to apply the patch in #192 on a Linux Server, I get the following error and the patch does not apply:
fatal: corrupt patch at line 501
When I try to apply the patch to a local Windows 7 system I get the following whitespace and /dev/null errors:
$ git apply -v entityreference-1253776-192_0.patch
entityreference-1253776-192_0.patch:9: trailing whitespace.
files[] = plugins/selection/views.inc
entityreference-1253776-192_0.patch:12: trailing whitespace.
files[] = views/entityreference_plugin_display.inc
entityreference-1253776-192_0.patch:13: trailing whitespace.
files[] = views/entityreference_plugin_style.inc
entityreference-1253776-192_0.patch:14: trailing whitespace.
files[] = views/entityreference_plugin_row_fields.inc
entityreference-1253776-192_0.patch:15: trailing whitespace.
fatal: git apply: bad git-diff - expected /dev/null on line 39
Comment #196
vgulla CreditAttribution: vgulla commentedThanks for the great module. It is exactly what I need.
I applied this patch on the latest dev version of the module and have the dev version of views too. But, I don't see the entity reference display as an option in the view. What am I missing?
This is the screenshot of the views editing page
Please help
Comment #197
vgulla CreditAttribution: vgulla commentedComment #198
vgulla CreditAttribution: vgulla commentedI applied the patch to the dev version of the module and am not able to see the entity reference display in the views. Please help.
Comment #199
tim.plunkettRestoring title.
@vgulla try clearing your cache.
Comment #200
marinoszak CreditAttribution: marinoszak commentedHello everybody!,
great patch, i applied it and then i created a reference view.
Seems to work fine but i have a problem when i use the aggregate function.
In the output of the view, below the configuration, aggregation works just fine but when i am in the product display node entity and try to reference other node entities, aggregation does not apply.
Is there any configuration i am missing?
See attached images below.
Comment #201
vgulla CreditAttribution: vgulla commented@tim.plunkett No luck even after clearing cache.
What could I be missing?
Comment #202
mrfelton CreditAttribution: mrfelton commentedPatch in #192 works really well. Just one small issue that we have. Our field is a required, single value term reference, using radio buttons as the selection method. The view used to limit the options is a simple listing of taxonomy terms that shows the term's title and an image field from the term. If no selection is made for this field and the submit button is pressed on the form, the form validation error message reads "An illegal choice has been detected. Please contact the site administrator." Rather than "X is a required field" as you would expect.
EDIT: Ignore - caused by something else.
Comment #203
vgulla CreditAttribution: vgulla commentedI am still not able to see the entityreference display type in views to make this work. This is driving me crazy. Please help.
I don't see any errors in the log too.
Comment #204
marinoszak CreditAttribution: marinoszak commented@vgulla Did you select "Entity selection mode * - Views: Filter by an entity reference view" on entity reference field (you have created) edit screen of the node bundle?
Comment #205
vgulla CreditAttribution: vgulla commentedYes. @marinoszak. If you mean the entity reference field in my CCK, I did it. Attached is the screenshot. The target type is of User.
Comment #206
vgulla CreditAttribution: vgulla commentedStill no luck. Can anyone help?
Comment #210
grantlucas CreditAttribution: grantlucas commentedHm. It had applied this patch a while back and moved on to different issues. Somewhere in the process, stuff broke. I had originally set up a view with the proper Entity Reference display but now, that display type is no longer showing up in the views selection. It's all there in the .views.inc file so am not too sure at this point what's going on. Also have nooo idea why it worked originally, but isn't now or why it stopped.
I believe this is also the issue @vgulla is seeing.
Can someone else re-apply patch #192 and let me know if you can see the needed display type in the views interface?
Much appreciated.
Grant
Comment #211
Itangalo CreditAttribution: Itangalo commentedI, too, don't get any results to show up in the Entity Reference widget. I do, however, get a notice and a warning in my log.
Notice: Undefined index: search_fields in entityreference_plugin_display->query() (line 77 of …/Sites/scorg/sites/all/modules/entityreference/views/entityreference_plugin_display.inc).
Warning: Invalid argument supplied for foreach() in entityreference_plugin_display->query() (line 77 of …/Sites/scorg/sites/all/modules/entityreference/views/entityreference_plugin_display.inc).
I hope to look more at this later today.
Comment #212
Itangalo CreditAttribution: Itangalo commentedEh. Found the issue for #211 – it was the old "error behind the keyboard". (It helps if you open the settings for the entity reference list style, and select which fields should be searchable.)
I'll be back.
Comment #213
Itangalo CreditAttribution: Itangalo commentedAttached patch includes a new Views validation, giving an error message if no search field has been selected.
It has also taken care of the style issues in #193.
(Applies to latest dev version.)
Comment #214
Itangalo CreditAttribution: Itangalo commented*grumble grumble*
Comment #215
Itangalo CreditAttribution: Itangalo commentedThere. Interdiff coming when I get power to my computer again.
Same as previous patch, but now with a Views validation that actually works.
Comment #216
Itangalo CreditAttribution: Itangalo commented…and there we go! Interdiff against #192.
Comment #217
vgulla CreditAttribution: vgulla commentedCan someone please help with this?
Comment #218
vgulla CreditAttribution: vgulla commentedI am using the 7.x-1.x-dev version (with patch in 215 applied to this) of entity reference and Views 3.x-7.x-dev
Should I be using something else for the entity reference display to show up in views
Comment #219
bartvdputte CreditAttribution: bartvdputte commentedIs anyone experiencing these kind of messages as well with patch #215 ? I'm getting these when I save a node that uses an entityreference field with this entityreference widget.
Notice: Undefined variable: wrapper in entityreference_field_presave() (line 249 of Users/USERNAME/Sites/SITE/sites/all/modules/entityreference/entityreference.module).
Notice: Trying to get property of non-object in entityreference_field_presave() (line 249 of Users/USERNAME/Sites/SITE/sites/all/modules/entityreference/entityreference.module).
Warning: Invalid argument supplied for foreach() in entityreference_field_presave() (line 249 of Users/USERNAME/Sites/SITE/sites/all/modules/entityreference/entityreference.module).
No idea why though...
Comment #220
grantlucas CreditAttribution: grantlucas commentedFor me, I'm still not getting the display type to show at all for selection in the views interface. Going to dive into the code for a bit to see if I can see what happened since it was working for me before.
Comment #221
grantlucas CreditAttribution: grantlucas commentedOh geez. I'm dumb on this one. It had been a while since I last had looked at this entity reference stuff and I was looking for the views display in the wrong part of the views UI. Please disregard my last few posts.
**Hangs head in shame.
@vgulla, In Views UI when you click +Add to add a new views display, do you see the Entity Reference option?
Comment #222
bartvdputte CreditAttribution: bartvdputte commented@grantlucas: I had a similar problem and it was because the patch did not create the necessary files inside entityreference/views. 3 NEW files should be added there, so after the patch you should have 4 files.
Patching it using git did solve the problem though...
I hope this works out your problem?
Comment #223
grantlucas CreditAttribution: grantlucas commented@bartvdputte yeah using git to apply patches is key now :)
Comment #224
vgulla CreditAttribution: vgulla commentedNo, I don't see it when I click the +add button. Attached is the screenshot. I have the 3 new files in views directory. I applied the patch manually.. since I am a little dumb and don't know how to use git. I am not sure if this makes a difference.
Comment #225
grantlucas CreditAttribution: grantlucas commented@vgulla Not doing it through git could very well be the problem. you may have missed something minor but important doing it manually. If you have GIT setup on your computer you need to clone the latest dev branch of entity reference, apply the patch, and then copy the resulting module folder to your site. That's the way i've been able to guarantee that it works.
So in a new folder run
git clone --recursive --branch 7.x-1.x http://git.drupal.org/project/entityreference.git
download the latest patch and move it to within that new entityreference folder and then run
git apply -v -p1 patch_name.patch
That should patch all the needed files. If you then run "git status" in the entity reference folder you should see a bunch of changed and new files.
Copy that entire folder to your site's module directory and let me know if it works out.
Comment #226
vgulla CreditAttribution: vgulla commentedNot to sound too stupid, but my site is hosted on godaddy linux server. How do I apply the patch using git there?
Can anyone send me the entity reference directory with the patch applied? Will that be easier
Comment #227
grantlucas CreditAttribution: grantlucas commentedOo, that's a much trickier situation. With experimental patches like these, it would be good to have a local test environment setup so you don't mess up a live site. Whether or not git is setup on your live site is dependant on godaddy. Just to see if things work, I've attached a zipped up copy of my patched entityreference module folder. You should be able to upload it to godaddy to replace the existing one. It's just the latest dev branch patched with the 215 patch. If it works, then we know your manual patch was missing something. If it doesn't work after clearing caches etc, then it's something bigger.
Comment #228
vgulla CreditAttribution: vgulla commentedthanks @grantlucas. I will try and get back
Comment #229
vgulla CreditAttribution: vgulla commentedThanks a lot @grantlucas for teaching me git. I used it as per your instructions and it worked. Obviously my manual method was error prone.
Thanks a lot for all of you for patiently listening.. much appreciated.
Comment #230
grantlucas CreditAttribution: grantlucas commentedRestoring title ;)
Glad it worked out.
Comment #231
grantlucas CreditAttribution: grantlucas commentedComment #232
ff1 CreditAttribution: ff1 commentedThe latest patch still works well for me.
I also tested the watchdog error messages described in #191 and they work. ie. when I disable a view that is used as an entity reference selection filter, a watchdog message is generated.
Unless anyone finds any other edge cases, I think the patch in #215 is RTBC.
Comment #233
bartvdputte CreditAttribution: bartvdputte commentedYes, it works OK here.
But I'm still getting variable undefined warnings... See: http://drupal.org/node/1253776#comment-5950712
Comment #234
marinoszak CreditAttribution: marinoszak commentedCan someone tell me why aggregation does not work with entity reference?
Thanks you too @grantlucas for the Git instructions!
Comment #235
TimG1 CreditAttribution: TimG1 commentedHi All,
I'm using patch #215 on -dev (2012-Mar-21)
Should this work for Field Collection Entities? I am still not able to get it to work. Selecting Field Collection from the Target Type options gives the message..."No eligible views were found. Create a view with an Entity Reference display, or add such a display to an existing view." see attached screenshot reference_field.png. However, I do have an entity reference field display created which is correctly showing the field collection results I want to appear in my dropdown. See attached screenshot my_view.png.
To replicate on a blank install...
Am I missing something?
Thanks for reading,
-Tim
Comment #236
tim.plunkettI can't tell 100% but it looks like that view is of nodes, not of field collections. It has to match the base table.
Comment #237
ff1 CreditAttribution: ff1 commented@TimG1: Try changing the target type to 'Article'...
Edit: Sorry, that should have said 'Node' not 'Article'.
Comment #238
TimG1 CreditAttribution: TimG1 commented@tim.plunkett #236, you were right on! That was my problem and it's working fine now. Kicking myself, didn't think to look at that.
Thanks again,
-Tim
Comment #239
Damien Tournoud CreditAttribution: Damien Tournoud commentedI ended up committing the following patch. Thanks, everyone!
Other then cleanups, the most notable change as compared to #215 is that
*::getReferencableEntities()
now returns labels as (safe) HTML.TODO for follow-up issues (any takers?):
_options_prepare_options()
(the select widget from core is broken)Comment #240
abtm CreditAttribution: abtm commentedAfter upgrading from 7.x-1.0-rc1 to 7.x-1.x-dev, this error "EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7539 of /var/www/drupal/includes/common.inc)." occurs every time when I try to edit the entityreference field. I upgrade views from 7.x-3.3 to 7.x-3.x-dev, the error remains. Did I miss anything?
Comment #241
mnlund CreditAttribution: mnlund commented#240 Same here.
Comment #242
ff1 CreditAttribution: ff1 commentedSee this issue: #1277376: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7390
You might want to try the debugging step mentioned here: http://drupal.org/node/1277376#comment-5642482
Comment #244
liquidcms CreditAttribution: liquidcms commenteddoes this work for users? when i add a User view and select to add an Entity Reference display i get taken here: http://screencast.com/t/sOLnbMwqF
Comment #245
liquidcms CreditAttribution: liquidcms commentedalso, on the field when setting entity reference mode to Views; i get the error: The selected selection handler is broken.
Comment #246
Crell CreditAttribution: Crell commentedLiquid: Please open that as a new bug issue. Don't open long-closed issues.