Hi !
How can i configure an ajax autocompletion from an external source for a dexterity field ( in Plone 5)
(let's say the external source is: json output from php-mysql)
Any help / link would be apreciated
Hi !
How can i configure an ajax autocompletion from an external source for a dexterity field ( in Plone 5)
(let's say the external source is: json output from php-mysql)
Any help / link would be apreciated
PS: This is not something I have done
I am not really sure what you need help to (do), but I think this is what you should do.
and when you got that working, modify the vocabulary
Reading the Json data is quite easy, maybe you can use something from here:
A vocabulary is static (it gets all its values on creation). Should that not be flexible enough, there is a generalization (called "Source") which allows for dynamic value determination,. Not sure, whether form.formwidget.autocomplete
requires a vocabulary.
Thank you Espen !
The data does come from a changing database
The idea is to help data entry assistants with an autocomplete list where they can choose a valid option from the database. Let's say the name of a company , or individual of interest.
Thank you Dieter !
i'm going to check that option
I never understood how to make it 'not static', but some of the vocabularies seem to work correct 'anyway', for example I have one that uses the image scale sizes, and I think it works correct after adding more image scales:
The naming (and maybe the realization as well) in zope.schema
related to the vocabulary
option of the Choice
field is not optimal. It allows as values either a vocabulary, a Source[Binder]
or the ZA-registered name for a corresponding factory.
The LeadImpageSizeVocabulary
in your example is not itself a "vocabulary" but a "vocabulary factory" (i.e. calling it results in a "vocabulary"). It constructs the real vocabulary (a SimpleVocabulary
) at its end. The factory can return vocabularies with varying terms, either based on different contexts or because a database has changed.
You use a "Source[Binder]" instead of a simple vocabulary when the number of potential values is so large that it becomes unfeasible to handle them as a "unit". Examples are "selecting a user" (with a huge user base) , "selecting an object", etc.
thanks for explaining, things are a bit clearer now