Autocomplete form with preselection

Re: Autocomplete form with preselection

by Andreas Stephan -
Number of replies: 0
Got it, actually it was very easy. You don't have to use valuehtmlcallback. Just pass in your selection inside addElement:

$mform->addElement('autocomplete', 'categories', get_string('categories', 'tool_webanalytics'), $selection, $attributes);

... where $selection is an associative Array, where key is your value and the array value is your label:
[
"your_value" = "your_label"
]
Average of ratings: Useful (1)