Autocomplete field in a database

Autocomplete field in a database

Lionel POUJET -
Кількість відповідей: 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

У відповідь на Lionel POUJET

Re: Autocomplete field in a database

William Lu -
Фото Particularly helpful Moodlers
Afaik Moodle database activity is not so smart yet усміхаюсь
У відповідь на William Lu

Re: Autocomplete field in a database

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 ?


У відповідь на Lionel POUJET

Re: Autocomplete field in a database

Daniel Thies -
Фото Core developers Фото Particularly helpful Moodlers Фото Plugin developers Фото 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