Hi

this is a support request, I will be glad if Marcus or somebody else could tell what can be the best option, how to give user autocomplete field with predefined words(cities), but still to give to him a chance to write own word(city) if he will find that it is not in the list.

my idea: the first autocomplete field, the second conditional field - checkbox "check if your city is not in the list" and after click there will be shown text input for writing a city.
I am curious if there is not some inbox solution working together with autocomplete field - if I write word what is not in list of words for this autocomplete field, then do condition/exception for adding this word:
a) into exist list for this field
b) into another cck text field

what you think about it?
thanks
Igor

Comments

markus_petrux’s picture

Status: Active » Fixed

If you use the "Autocomplete for existing field data" widget, the user will be able to reuse cities already entered on that field, or simply add new cities if they need to.

If you use the "Autocomplete for allowed values list" widget, then you can use PHP code to configure the allowed values of the field. This PHP code can read the values from database, or whatever else you may need. But the user won't be able to use values that are not in the predefined list. So here you need something like conditional fields, to allow the user to provide a new city from a separate field, and then add some kind of post processing to insert new values to the allowed list.

The former looks less complex to implement, and also more user friendly, I guess.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

interestingaftermath’s picture

igorik - Did you ever come up with a reasonable solution for this?

igorik’s picture

Hi, no, I am using current, not the best solution - list withe predefined words, however I would very welcome some solutions for list of predefined words together with the option to add new words if there something will be.

djroshi’s picture

please review my patch here, which provides this functionality by allowing "existing field data" to use any cck field:

http://drupal.org/node/564648

you would need to store the predefined 'cities' in a cck field and then lookup suggestions from that field. Users will be provided with suggestions from that field, but won't be forced to use those values and can enter whatever they like. Let me know if you need any help with setting this up.

I have tried to use conditional fields with autocomplete widgets but that didn't really work...