have the problem which I’m trying to solve whole day, and it left me without any more ideas.
In my paragraph, I want to create autocomplete using module "select 2" and php.
I have an associative array – ("key" => "value"); How to implement autocomplete so I can filter it by both things above? I need to use key as an parent, and value as a child.
$form['reference']['#type'] = 'select2';
$form['reference']['#select2']['allowClear'] = FALSE;
$form["reference"]["#options"] = array(
"key1" => "value1",
"key2" => "value2",
"key3" => "value3"
);
This was my attempt in form_views_exposed_form_alter.
Idea is to be able to search by keys and by values, but it does not showing that possibility.
-if i need to to do it via ajax or it can be pre populated anything will do i just need correct format to set key values pairs
-example search: value1 => returns value1 key1 => returns value1
The link of the module which I’m using is:
https://www.drupal.org/project/select2
Thanks in advance!
Dusan