Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
6.x-2.x-dev
Component:
text.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Mar 2007 at 20:47 UTC
Updated:
15 Jan 2011 at 19:27 UTC
Is there a way to have the drupal autocomplete feature on a CCK textfield?
Comments
Comment #1
yched commentedit is not built in. What do you want to complete with ? existing values for the field ?
I guess it's a feature request...
But you can also come with a form_alter in a custom module of yours, and specify your own '#autocomplete' path.
See Form API documentation about that.
Comment #2
fagoI think there's already an autocomplete widget in the CCK taxonomy module (content_taxonomy). Perhaps this one should be adapted to be generic, so that it works with text fields too.
Comment #3
lefnire commentedbump, this should be implemented.
Comment #4
cgjohnson commentedI second that!
Comment #5
moshe weitzman commentedGood idea to use existing values as suggestions in autocomplete.
Comment #6
FiReaNGeL commentedI can say that this would have been a nice feature to have; I don't know about the inner workings of CCK, but I think this would be relatively easy to implement.
Comment #7
SamRose commentedIn reply to number 2 above, I am looking into doing this now...
Comment #8
brunodboPerhaps http://drupal.org/project/textfield_autocomplete can help?
Comment #9
Jeremy Toaster commentedThat module is only for 5.x-1.x-dev
I run a record label site in which people enter their bands concert dates. Either having Auto complete or a way to store venue information and have it populate the fields upon selection with auto complete would be wonderful to have in 6.x and up.
jeremy
Comment #10
gagarine commentedtrack
Comment #11
SamRose commentedIn response to http://drupal.org/node/126595#comment-1007877
maybe http://drupal.org/project/textfield_autocomplete could be ported forward to D6?
Comment #12
profix898 commentedAny news here? I'm also hoping for a textfield with autocompletion from previous entered values.
Comment #13
Coupon Code Swap commentedSubscribing
Comment #14
Apollo610 commentedI would also be interested in some sort of autocomplete implementation into CCK as well.
In my use case, it would essentially take the place of ridiculously long select-lists (one of my lists could potentially be over 300 rows, not very friendly for users to have to scroll through). So as long as we could enter values when creating the field similar to how select lists are currently handled (or be able to point to a drupal table/field), I think this would be perfect in CCK.
Thanks!
Comment #15
yched commentedWe could add options to the textfield widget :
- no autocomplete (current behavior)
- autocomplete, fetch values from the list of allowed values
- autocomplete, fetch values from the existing values in the field.
I don't intend to work on this myself in a near future, but patches are welcome. Shouldn't be *too* hard...
Comment #16
vacilando commentedI support this idea a lot.
Comment #17
aleagi commentedHi,
It will be really great to have this options on textfields! @:)
Good work on that guys!
Comment #18
patchak commentedI offer to sponsor 150$ for this. Please contact me if you are ready to provide a good working patch to provide this functionnality!!! thanks a lot!!
Patchak
Comment #19
markus_petrux commentedThere's a module for Drupal 5 that seems to do this. I'll try to contact the author (linuxbox). If he's not up for porting the module to Drupal 6, then I'll ask him to transfer maintainership of the module, so I can do it.
In any case, if linuxbox does not respond soon, I can do this anyway and post it in the textfield_autocomplete issues queue.
Comment #20
patchak commentedMarkus : cool! Thanks for the message and let me know how it goes!
Comment #21
zmove commented/subscribe to the idea
Comment #22
marcvangendsubscribe, this would be a great feature.
Comment #23
markus_petrux commentedI have written this as a contrib module that's on my sandbox now, temporarily. I posted about it here:
http://drupal.org/node/281885#comment-1233218
@KarenS/yched: could you please take a look at the code and see if it worths for CCK, or otherwise it is jusy fine as a contrib module? Thank you so much.
The code can be found here:
http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/markus_petr...
If it has to live as a contrib, the I guess this issue could be closed.
Comment #24
karens commentedThis looks very interesting. yched, what do you think? It might also be something to push into the D7 fields as a generic field.
Comment #25
markus_petrux commentedI was about to create a new module named autocomplete_widgets, as it would complement optionwidgets currently in CCK. I may wait a little if you feel this could integrated into CCK itself.
Comment #26
yched commented+1 on the principle, a few remarks from a cursory look :
- Markus, not sure why you chose to write this as two separate widgets instead of one widget with a setting ?
- The code looks like it would be not that many lines if merged with the current text.module
- But then that code would need to be duplicated if we wanted the same feature on number fields. Maybe we can live with that.
Not much more articulate thoughts at this time of the day :-)
Comment #27
markus_petrux commentedBecause one of the widgets (the one based on allowed values list) applies to both text and number fields, but the other (the one that takes candidates from existing field's data) applies only to text fields.
IMHO, it is necessary this feature for number fields. You may have a list of allowed values, but need numbers in the DB. I hope that makes sense.
There are 2 things I'm not happy with:
1) What happens if the user changes the widget type when the field has already data in it. Should this be allowed in all cases?
2) The name of the widgets: Autocomplete text field (limited) -vs- Autocomplete text field (unlimited) ¿?
Edited: As per the name of the module, since we already have "Option Widgets", I would suggest here "Autocomplete widgets".
Comment #28
marcvangendI just noticed that archard has recently published a module for this: http://drupal.org/project/cck_autocomplete. I didn't try it yet, but it might be a good starting point.
Just a thought:
An autocomplete textfield needs a datasource (defined as the #autocomplete_path value, http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...). A sensible default would be to autocomplete existing values for that field, but it would be great if we can allow a custom datasource. The simple way would be a setting where you can enter the custom autocomplete path. But maybe it would me much nicer to create a new hook (hook_autocomplete?) so modules can publish an autocomplete data source by implementing this hook.
Comment #29
markus_petrux commentedIn the module I did, you can choose the widget that takes candidates from Allowed values list, and there you can use a custom PHP function to generate the values dynamically. ;-)
Comment #30
marcvangendOf course! I don't know why I forgot that you can use php to load allowed values...
Still, it wouldn't be very efficient when you combine it with functions that already generate autocomplete values. Take user_autocomplete() for instance: it returns a JSON object. The allowed values PHP would have to convert this into an array, only to be turned into JSON object again by your module...
Comment #31
markus_petrux commented@marcvangend #30: Well, if I was to release this as a module, then I wouldn't evaluate feature requests until then.
@KarenS/yched: Could you please review comment #27 above? I'm interested to know if you would include this in CCK itseld, otherwise I would create a separate project. Please, let me know if you wish anything changed, or if you wish a patch, etc. I would really be glad to work on it until it's done. :)
Comment #32
markus_petrux commentedWell, I ended up creating a separate project for feature. It can be found here:
http://drupal.org/project/autocomplete_widgets
Cheers
Comment #33
marcvangendThanks Markus, I'll give it a spin soon.
Comment #35
off commentedAny solution for drupal 7?