SingleValueSearchControl: Add default class to the search suggestions

This commit is contained in:
Yonas Habteab 2022-05-06 10:23:43 +02:00 committed by Johannes Meyer
parent e602db3073
commit 2279502265
1 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,7 @@
namespace Icinga\Web\Widget; namespace Icinga\Web\Widget;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
use ipl\Html\Attributes;
use ipl\Html\Form; use ipl\Html\Form;
use ipl\Html\FormElement\InputElement; use ipl\Html\FormElement\InputElement;
use ipl\Html\HtmlElement; use ipl\Html\HtmlElement;
@ -177,6 +178,7 @@ class SingleValueSearchControl extends Form
} }
} }
$index = 0;
foreach ($entries as list($label, $metaData)) { foreach ($entries as list($label, $metaData)) {
$attributes = [ $attributes = [
'value' => $label, 'value' => $label,
@ -187,7 +189,9 @@ class SingleValueSearchControl extends Form
$attributes['data-' . $key] = $value; $attributes['data-' . $key] = $value;
} }
$ul->addHtml(new HtmlElement('li', null, new InputElement(null, $attributes))); $liAtrs = ['class' => $index === 0 ? 'default' : null];
$ul->addHtml(new HtmlElement('li', Attributes::create($liAtrs), new InputElement(null, $attributes)));
$index++;
} }
} }