Source
foreach (['defaultValue', 'disabled', 'selectedLimit', 'addNew', 'styles', 'placeholder', 'hidden', 'readonly']
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CMultiSelect extends CTag {
/**
* Default CSS class name for HTML root element.
*/
const ZBX_STYLE_CLASS = 'multiselect-control';
/**
* Search method used for autocomplete requests.
*/
const SEARCH_METHOD = 'multiselect.get';
const FILTER_PRESELECT_ACCEPT_ID = 'id';
/**
* @var array
*/
protected $params = [];
/**
* @param array $options['objectOptions'] An array of parameters to be added to the request URL.
* @param bool $options['multiple'] Allows multiple selections.
* @param bool $options['add_post_js']
*
* @see jQuery.multiSelect()
*/
public function __construct(array $options = []) {
parent::__construct('div', true);
$options = $this->mapOptions($options);
$this
->setId(zbx_formatDomId($options['name']))
->addClass('multiselect')
->setAttribute('role', 'application')
->addItem((new CDiv())
->setAttribute('aria-live', 'assertive')
->setAttribute('aria-atomic', 'true')
);
if (array_key_exists('disabled', $options) && $options['disabled']) {
$this->setAttribute('aria-disabled', 'true');
}
if (array_key_exists('readonly', $options) && $options['readonly']) {
$this->setAttribute('aria-readonly', 'true');
}