Skip to content
Snippets Groups Projects

webform-3473045: Fix Autocomplete STARTS_WITH

Compare and
4 files
+ 283
17
Compare changes
  • Side-by-side
  • Inline

Files

@@ -203,21 +203,30 @@ class WebformElementController extends ControllerBase {
// Cast TranslatableMarkup to string.
$label = (string) $label;
if ($operator === 'STARTS_WITH' && stripos($label, $q) === 0) {
$matches[$label] = [
'value' => $label,
'label' => $label,
];
}
// Default to CONTAINS even when operator is empty.
elseif (stripos($label, $q) !== FALSE) {
$matches[$label] = [
'value' => $label,
'label' => $label,
];
switch ($operator) {
case 'STARTS_WITH':
if (stripos($label, $q) === 0) {
$matches[$label] = [
'value' => $label,
'label' => $label,
];
}
break;
// Default to CONTAINS even when operator is empty.
default:
if (stripos($label, $q) !== FALSE) {
$matches[$label] = [
'value' => $label,
'label' => $label,
];
}
break;
}
}
}
}
Loading