protected function YamlFormOptionsController::appendOptionsToMatchesRecursive in YAML Form 8
Append form options to autocomplete matches.
Parameters
string $q: String to filter option's label by.
array $options: An associative array of form options.
array $matches: An associative array of autocomplete matches.
1 call to YamlFormOptionsController::appendOptionsToMatchesRecursive()
- YamlFormOptionsController::autocomplete in src/
Controller/ YamlFormOptionsController.php - Returns response for the element autocompletion.
File
- src/
Controller/ YamlFormOptionsController.php, line 68
Class
- YamlFormOptionsController
- Provides route responses for form options.
Namespace
Drupal\yamlform\ControllerCode
protected function appendOptionsToMatchesRecursive($q, array $options, array &$matches) {
foreach ($options as $value => $label) {
if (is_array($label)) {
$this
->appendOptionsToMatchesRecursive($q, $label, $matches);
}
elseif (stripos($label, $q) !== FALSE) {
$matches[] = [
'value' => $value,
'label' => $label,
];
}
}
}