7

Does anybody know of a Drupal 7 autocomplete widget for textfields? I've tried Autocomplete Widgets, but the "Autocomplete for allowed values list" widget from that doesn't seem to exist in Drupal 7 -- only the other two widgets show up. My goal is to store plain text but autocomplete from a user profile field. Thanks!

3 Answers 3

6

Creating autocomplete for a Drupal form textfield is pretty easy.

  1. Add the #autocomplete_path to the form element
  2. Create a menu callback that returns JSON data with drupal_json
7

Try http://timonweb.com/how-create-ajax-autocomplete-textfield-drupal-7

ALSO: http://qandeelaslam.com/blogs/cck/converting-texfield-autocomplete-using-drupals-form-api http://www.elevatedthird.com/blog/enable-ajax-autocomplete-drupal-7-webform-textfield

(Looking for a module, now.)

3

There is http://drupal.org/project/autocomplete_widgets:

This module adds 3 autocomplete widgets for CCK fields of type Text and Number.

Autocomplete for allowed values list: This widget can be used for Text and Number fields and it takes candidate values from the defined list of Allowed values of the fields. You can even generate your allowed values list using PHP, so the limit to provide a widget with autocomplete features is your imagination!

Autocomplete for existing field data: This widget can be used for Text only and it takes candidate values from existing values in the database for that field.

(7.x only) Autocomplete for predefined suggestions: This widget can be used for Text only and allows an admin to provide a list of suggestions but still allows users to enter anything they want in a text field. Use this widget to help avoid (but not prevent) variations of the same value. Ex: burger, hamburger, Burger ...

(7.x only) Autocomplete for existing field data and some node titles: This widget works just like the "existing field data" widget above except it will also suggest node titles for nodes of a specific content type(s).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.