Background is all in #1389238: Autocomplete widget improvements. However that issue is in a confused state. The issue was originally a feature request. Subsequently it was re-opened and comments were added to observe the feature was later broken. However the category is still "Feature request" the issue is quite old, the title doesn't reflect the current bug - and so I think the new problem has got lost.
Here's a summary of the status:
- Auto-complete widget was enhanced to support using user-supplied value when user does not use the auto-complete functionality. This scenario can occur if scripts are disabled, or if you press tab/escape without letting the auto-complete script add it's entity ID in brackets.
- A subsequent check-in broke this enhancement.
- It's now worse than if the feature didn't exist at all. If you try to use the feature, the field ends up with no value - even if it is a required field.
There is a patch in #1389238: Autocomplete widget improvements.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | entityreference.1389238-43.patch | 1.03 KB | adamps |
| #6 | entityreference-autocomplete-widget-2375957-6.patch | 976 bytes | nikita petrov |
Comments
Comment #1
nikita petrov commentedAdamPS, I expirienced that problem too. My customer paid me for fixing that problem and I found the way to check whether the user's manual entry have the corresponding entity in our site or not. If there is no appropriate value then I throw a form error 'There is no entity for that input' and ask the user to fill the correct value in that field. Please, correct me if I misunderstand something, the code from the following path is working for me: (I will atach it to the next comment).
Comment #2
nikita petrov commentedI'm sorry, how to delete the duplicated comment?
Comment #3
nikita petrov commentedI'm sorry, how to delete the duplicated comment?
Comment #4
nikita petrov commentedI'm sorry, how to delete the duplicated comment?
Comment #5
nikita petrov commentedI'm sorry, how to delete the duplicated comment?
Comment #6
nikita petrov commentedHere is the patch for solving my problem. Is it correct?
Comment #8
adamps commented@Nikita thanks for taking the time to respond. However as I said in my original issue
The next step is to persuade the maintainers to commit the fix. Sorry, I should have set the status of the issue to indicate this. I will also copy the patch across here.
NB this patch is an exact copy of the one by sammys on the related issue. Please send all credit to him. I have only copied it here to help make it clear that this issue is ready for commit.
Comment #9
adamps commentedComment #10
nikita petrov commentedThank you, Adam, sorry for my interferencing here.
Comment #11
Garrett Albright commentedPatch in #8 fixes a bug we were experiencing on a client site which sounds a bit different from the OP:
This was because the value that would eventually be returned from this method was the entity type name instead of the entity ID, and that value was later being discarded down the line without the validation failure reaching back up to the entity form.
+1 for RTBC.
Comment #12
13rac1 commented+1 for #8. Works well.
Comment #13
ikeigenwijs commentedPatch in #8 did not fix it for us.
In xdebug did step by step
The function validateAutocompleteInput in EntityReference_SelectionHandler_Generic.class.php is never hit.
The following validation function is hit in entityreference.module
Comment #14
adamps commented@ikeigenwijs If validateAutocompleteInput is not hit at all then I would say that you have a different problem from the one in this issue. The patch merely fixes the code within the function, which of course can only help you once you have solved the bug that means the function isn't being called on your site.
It's a while since I've looked at this code, and I'm not an expert - but if I remember correctly, some client side javascript should trigger a call to validateAutocompleteInput as you start to type. Perhaps you have some other javascript file that has a bug in which is preventing other scripts from running? You can check the console output in Firebug on Firefox or whatever equivalent tool you prefer.
entityreference_field_validate I think gets called when you actually submit, so the timing is different.
Comment #15
ikeigenwijs commentedthx for the tip I will search in that direction.
Comment #16
mgiffordSo no longer RTBC @ikeigenwijs?
Comment #17
ikeigenwijs commented@mgifford,
AdamPS suggested that my problem of the validation is related to the Ajax.
But i cant find where the call should originate to trigger the validation.
The code of the validation itself looks sound, its just not triggered on my install and cant find out why :s
Comment #18
adamps commentedFrom a quick look
If you need further help, please post your own issue (or maybe http://drupal.stackexchange.com/) rather than hijacking this issue :-).
Comment #19
damienmckennaComment #20
adamps commented@DamienMcKenna Thanks - you are a busy man with so many modules to look after! NB as per #8 I copied the patch here from the related issue, please send credit to sammys if you remember.
Comment #21
damienmckenna@AdamPS: I'm not a comaintainer of ER, just trying to help cheerlead the next release :)
Comment #22
azinck commented#8 works for me, confirming RTBC.
Comment #23
anybody+1 for RTBC
Comment #24
dbiscalchin commented#8 RTBC
Comment #25
anrikun commentedThis is a duplicate of #1974202: Values not saved when not selected from the autocomplete menu which was created even earlier.
Patch proposed there is almost the same.