Autocomplete field in a database

Autocomplete field in a database

by Lionel POUJET -
Number of replies: 4

Hello,

I would like to use an autocomplete field based on a list.

User should type the first characters in the field in order to get the first possibles occurencies in the given list.

Thanks a lot for your help

Best regards

Lionel

Average of ratings: -
In reply to Lionel POUJET

Re: Autocomplete field in a database

by William Lu -
Picture of Particularly helpful Moodlers
Afaik Moodle database activity is not so smart yet smile
In reply to William Lu

Re: Autocomplete field in a database

by Lionel POUJET -

Thanks a lot for your answer ! 

🤔 do you think that it would be possible by using javascript like :

label my moodle db field and hide it as myfield for example

giving an autocompleting field thanks to javascript

filling "myfield" from the javascript autocompleted field

Might it could be possible ?


Average of ratings: Useful (1)
In reply to Lionel POUJET

Re: Autocomplete field in a database

by William Lu -
Picture of Particularly helpful Moodlers
It would be really smart if you could do it, looking forwards to seeing your preset shared here.
In reply to Lionel POUJET

Re: Autocomplete field in a database

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Lionel,

Excellent idea! The standard autocomplete element is created with a template here https://github.com/moodle/moodle/blob/master/lib/form/templates/element-autocomplete.mustache. You can see where the javascript is loaded at the bottom. You should be able to copy that and replace placeholders with the correct css selector and other options.

Daniel

Average of ratings: Useful (1)