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.
Free tagging entity reference to a vocabulary does not create the term, only allows existing terms.
attached is a screenshot of my field settings
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedYes, that's by design. Entity Reference doesn't create entities.
Comment #2
dgtlmoon CreditAttribution: dgtlmoon commentedSo why does it allow me to type in a term?
Comment #3
dgtlmoon CreditAttribution: dgtlmoon commentedNeeds to be a bit more obvious, patch coming with perhaps something to place some text to let me know that this field does not create at term
Comment #4
amitaibu@dgtlmoon,
It would be great if you can provide a patch with some text for the README.txt to let people know that ER can be used only for referencing.
Comment #5
amitaibuAs part of porting Og-vocab to D7, I was able to create terms using ER. I think it can be a nice feature, for each entity type to say if it's auto-creatable. Patch will land in a couple of days.
Damz, any objections?
Comment #6
amitaibuCompletely un-tested.
Comment #7
kunago CreditAttribution: kunago commented@Amitaibu: I tried your patch but it does not validate against newest changes. From my position of having low experience comapred to what you have I still dare to ask:
Other than that I wish I was able to take a look at this functionality because this is what I have been after.
Comment #8
star-szrClosed #1791206: autocomplete(tags style) errors on validation if term is new and says: There are no entities matching "test" as a duplicate of this issue.
Comment #9
amitaibubtw, OG-vocab already has code that does it for terms.
Comment #10
hgurol CreditAttribution: hgurol commentedI wish someone with the required skills have the time to take a look at the code in OG-vocab and replicate it in this module.
Comment #11
Rob230 CreditAttribution: Rob230 commentedAre there any plans to support this? Would have really helped me out.
Taxonomy Term Reference Filter by Views is an alternative, but it puts the term ID in brackets after the name, which is totally undesirable for me. Entity reference doesn't do that, but it won't let people add terms.
Comment #12
hgurol CreditAttribution: hgurol commentedAmitaibu says the required code is already in the og_vocab module. I am guessing, It shouldn't be too much work for someone who has some coding skills.
@DamZ
I don't wanna sound rude but either that option is mis-named, or this is a bug/missing feature for the module. It's very hard to accept that "it works as designed". I have no doubt; 9 out of 10 site builders would expect the new term to be created if that "Autocomplete, Tag Style" option is used.
Thanks...
Comment #13
Yuri CreditAttribution: Yuri commentedSo am I correct, if the Entity Reference module is still not replacing previous modules like Term References? I thought that was the purpose of ER, to integrate that all by using entities. It is indeed confusing that 'Autocomplete Tag Style' can be selected, because tagging should create tags automatically.
Comment #14
bgilhome CreditAttribution: bgilhome commentedHere's a patch based on the og_vocab code. It adds references in autocomplete tags style widgets by checking for "(id)" suffix, or searching existing terms by name (matching first vocab sorted by order in field target bundles settings), or creating new term if no existing term found.
Comment #15
hgurol CreditAttribution: hgurol commented@bgilhome
Thanks for taking the time. I am testing this patch. As long as I can see, it works great when a single new term is used. I have tried many different combinations that works.
NEWterm
existingterm1, NEWterm
NEWterm, existingterm1
existingterm1, existingterm2, NEWterm
existingterm1, NEWterm, existingterm2
NEWterm, existingterm1, existingterm2
These all works fine. However, there is a problem when 2 new terms are used.
NEWterm1, NEWterm2
For me, its not a big deal but I can't speak for others.
Comment #16
vgalindus CreditAttribution: vgalindus commentedHi i've been working on this too and I was considering create a separate module for it. That depends on entity reference maintainers but if this is going to be added I think it should let you chose wether to allow free tagging or not at a field level. I will try to make a patch from the code I have if you want. BR
Comment #17
hgurol CreditAttribution: hgurol commentedI say; It makes a lot more sense to have it as a part of this module, rather than having it on a separate one.
Comment #18
vgalindus CreditAttribution: vgalindus commentedTest this one.
Comment #19
bgilhome CreditAttribution: bgilhome commentedSeems to be working for me, nice one!
Comment #20
hgurol CreditAttribution: hgurol commented@galindus_olidop
1- When I create my new field with ER, first I am at the "field settings" page, where I check the "Create terms if no matches." and I hit save. Now I am at the "my new field settings" page which is has more detailed options. The same check box for creating new terms is now uncheched. I have to re-check it again on this page. Either my previous selection should be carried over here or maybe its better to have that option on only one page, not two.
2- All single term tests works without a problem. I tried all combinations like I mentioned at #15.
3- There is a problem while trying to create multiple terms, which I can not place my finger on top of it. First, it doesnt happen all the time. Second, even if I get that Ajax error message, I see that the terms are created correctly after I click ok on the error message. I dont know what causes the error. First I thought it is related with the placement of the new terms since I try mixing the new terms with the existing ones in different orders. Then I thought it happens while editing an existing content rather than when creating a new one. But still I couldnt pin-point when it exactly happens. Please see the attachement for the error message. And it would be great if someone else tests this with multiple terms, it might have something to do with my own setup.
Thanks...
Comment #21
bgilhome CreditAttribution: bgilhome commentedI needed to add a line after 473 of entityreference.module:
in order to save the checkbox setting. I haven't encountered the error message from above comment.
Comment #22
vgalindus CreditAttribution: vgalindus commentedHi,
@bgilhome
I have clean a bit the code and added #21, thanks.
@hgurol
I have test it with a clean install and I can't reproduce your error, but due the fact the error is thrown on the ajax call it can't be (or shouldn't) the changes done by that patch.
Comment #23
vgalindus CreditAttribution: vgalindus commentedTested patch in dev branch and works ok.
Comment #24
hgurol CreditAttribution: hgurol commentedAlright, I have tested the patch in #22 on a different (fresh) setup.
Now the selection about creating new terms carries over to the 2nd config page.
And I don't get any weird Ajax errors I have mentioned earlier.
All looks good and I feel safe to change the status.
Thank you guys...
Comment #26
sammys CreditAttribution: sammys commentedI have reworked the patch to match Drupal coding standards and cleaned it up a little (reduced bloat). Tested it and it's working.
Related to this is #1959624: Autocomplete widgets not referencing the single entity result. Perhaps a maintainer can now guide both of these towards commit.
Comment #27
sammys CreditAttribution: sammys commentedI've incorporated the changes from #1959624: Autocomplete widgets not referencing the single entity result and marked that issue as a duplicate of this one. Patch attached. Changing this to a feature request since this was not in the module original design.
Comment #28
sammys CreditAttribution: sammys commentedI've moved part of the patch into another existing issue: #1389238: Autocomplete widget improvements
So, here are two patches. The first patch includes the functionality provided by the aforementioned issue. The second will work once you have applied the patch in the aforementioned issue.
This patch has overhauled the previous way this was done. Entity creation is no longer term specific and the EntityReference_SelectionHandler interface has been extended to support entity creation and field settings form validation. I have supplied a generic
entityCreate()
implementation and one for terms. There are likely to be problems with other entities but further testing will iron those out.Views selection does not have creation support at this point. We shouldn't add that until this patch gets committed.
Please test this patch with your weird and wonderful entity references and let's get this into the codebase! :)
Comment #29
vgalindus CreditAttribution: vgalindus commented#28: 1472596-28.patch queued for re-testing.
Comment #30
vgalindus CreditAttribution: vgalindus commentedHi Sammys, first of all thanks for fixing the patch. I have tried to apply the patches , first #1389238 and then #1472596 but this one fails.
Anyway thinking about this there are some things that are not clear to me. If final solution will not allow us to use views I think this is not an improvement since core taxonomy already has free tag with autocomplete widget and we would replicate the same behavior, the second one is if allowing entity creation with free tags widget wouldn't be the same behavior as entityconnect offers.
Best regards
Comment #31
hgurol CreditAttribution: hgurol commentedI did the same tests I did before with patch 1472596-28.patch
It applies well, works well. I did not encounter any problems.
What kind of a test should I do for views integration?
Comment #32
whastings CreditAttribution: whastings commentedI gave the patches a try, and they look solid. I was able to create new terms without any issues.
Comment #33
vgalindus CreditAttribution: vgalindus commentedHi all,
@hgurol
I don't have much time right now to test but the views integration you should use a view to select the entities (though it is not working according to sammys) it is not a big problem though if someone wants to display a custom dropdown list it will not be possible to add terms. I think the fix goes in the right direction, adding views support would be the next action IMO.
BR!
Comment #34
grpenner CreditAttribution: grpenner commentedIs this patch included in the latest release? I am using og_vocab in Open Atrium 2 and I am not able to free tag. I have the latest release of the entity reference extension.
Greg
Comment #35
DamienMcKenna@grpenner: As you're relatively new to d.o I'll explain how the issue status works.
When an issue is being discussed it will have the status "Active".
When someone writes a patch and uploads it the status will be changed to "Needs review".
After people review it, if there are problems with the patch, or it otherwise needs further work, the status will be changed to "Needs work", which will then loop back to "Needs review" when a new patch is uploaded.
After (hopefully) several people review the patch and believe it works well, the status will be changed to "Reviewed & tested by the community", which is how we tell the maintainer that we believe it's ready to be committed. Note, however, that the maintainer may test out the patch themselves and skip this step.
When the maintainer commits the patch the status will be changed to "Fixed". At this point the change will be available from the project's -dev release, there is no automatic process of creating a new stable release just because someone commits a change. Note that the status will be automatically changed to "Closed (fixed)" by the system two weeks after the issue is changed to "Fixed".
Because this issue's status is "Needs review" it indicates that the fix has not been committed, therefore it is not in the -dev release nor is it in the most recent stable release. It would be really great if you could take a bit of time to test out the patch and report back whether it works for you.
Thanks for contributing!
Comment #36
DamienMcKennaFYI https://drupal.org/project/entityconnect was mentioned as a possible temporary work-around.
Comment #37
DamienMcKennaHiding all but the most recent patch.
Comment #38
Charles BelovI was only able to reproduce this problem with a fresh taxonomy. After that, I am unable to reproduce the issue.
Comment #39
Yuri CreditAttribution: Yuri commentedI confirm that patch #28 works.
Not related to this issue probably, but tags that are found in the field, show the term ID behind it. Don't think that is needed.
By the way, I'm using this in combination with Active Tags module and this patch https://drupal.org/node/1912156..works great!
Comment #40
mvdve CreditAttribution: mvdve commentedThe development snapshot of Entityreference_autocreate works like a charm and looks like it is exactly what is needed.
Comment #41
quotesBro CreditAttribution: quotesBro commented@mvdve, thanks! Entityreference_autocreate works for me too.
Comment #42
caschbre CreditAttribution: caschbre commentedSo it sounds like we have several options here.
* Patch #28
* Entityreference Autocreate
* Entity Connect
* References Dialog
Comment #43
ikeigenwijs CreditAttribution: ikeigenwijs commentedWas looking high and low to find this. We thought entity reference was also a drop in replacement for term reference. (guess again ;-))
For getting back the free tagging functionality of terms/basic taxonomy with no additional mandatory fields the
Entityreference Autocreate path is the best solution.
We use this now
For nodes and more complex content
Entity Connect is the better solution. But we have some issues with disappearing add buttons and so on.
Comment #44
julia.klimovsky CreditAttribution: julia.klimovsky commentedReroll to the HEAD of 7.x-1.x
Comment #46
julia.klimovsky CreditAttribution: julia.klimovsky at Sitrus Agency commentedAdjust tests: fix $element mock in entityreference.handlers.test
Comment #47
J-LeeThe patch from #46 is working form me since a few weeks without issues.
RTBC ?
Comment #48
candelas CreditAttribution: candelas commentedI confirm that patch #46 works with last dev 7.x-1.2+20-dev
Thanks @julia.klimovsky
Comment #49
candelas CreditAttribution: candelas as a volunteer commentedHello
The patch keeps working with 7.x-1.4, but this
--- tests/entityreference.handlers.test
+++ tests/entityreference.handlers.test
@@ -199,6 +199,7 @@
$handler = entityreference_get_selection_handler($field);
$element = array(
'#parents' => array('element_name'),
+ '#field_name' => $field['field_name']
);
$form_state = array();
$form = array();
Thanks for the patch @julia.klimovsky
Comment #50
asrobI cannot apply patch #46 in branch 1.x-dev, that's why I changed its status.
Comment #51
thtas CreditAttribution: thtas commentedI'm not sure if anybody else is in the same boat, but because of the entityreference security update in 7.x-1.5 I've re-rolled the patch to work against that specific tag.
see attached.
(this also works against current 7.x-1.x dev)
Comment #52
asrobLooks good to me, I've successfully applied this patch above.
Comment #54
candelas CreditAttribution: candelas as a volunteer commentedThanks @thtas, patch #51 works perfect in 7.x-1.5
Comment #55
candelas CreditAttribution: candelas as a volunteer commentedI think this patch has been tested enough and it is a very needed feature. Thanks all for the work :)
Comment #56
Zythyr CreditAttribution: Zythyr commentedAre there any plans to incorporate the working patch into stable release?
Comment #57
GuyPaddock CreditAttribution: GuyPaddock at Inveniem commented@candelas: I don't disagree with you; but the patch will still need work to match the code style checks the maintainer has activated, per #53.
Comment #58
GuyPaddock CreditAttribution: GuyPaddock at Inveniem commentedI looked over the style issues that Coder flagged above in #53, and many were pre-existing issues in this module, with the exception of a couple dozen that were new. As the primary focus of this issue was to address the limitation that terms could not be created on-the-fly, I took a stab at correcting only the low-hanging fruit -- code style issues introduced in areas of code that #53 already touched.
Attached is a revised version of the patch from #51 with the style issues that patch introduced (hopefully) addressed. I've also attached an interdiff to make the changes more obvious.
Hopefully this makes the code sniffer happy :)
Comment #59
GuyPaddock CreditAttribution: GuyPaddock at Inveniem commentedHere's the interdiff.
Comment #60
candelas CreditAttribution: candelas as a volunteer commentedThanks @GuyPaddock
Your patch in #59 works with 7.x-1.9
Comment #61
joseph.olstadtriggered tests on all supported versions of PHP
Comment #62
joseph.olstadfuzz cleaning
Comment #65
joseph.olstad@candelas , what version of PHP are you using?
Comment #66
joseph.olstadThis patch needs fixing for PHP >=7.4+
Needs work.