Source
<?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 CRadioButtonList extends CList {
/**
* Default CSS class name for HTML root element.
*/
const ZBX_STYLE_CLASS = 'radio-list-control';
const ORIENTATION_HORIZONTAL = 'horizontal';
const ORIENTATION_VERTICAL = 'vertical';
private $name;
private $value;
private $orientation;
private $enabled;
private $readonly;
private $modern;
private $autofocused;
private $autocomplete = true;
/**
* Array of value elements.
*
* string $values[]['name'] Input form element label.
* string $values[]['value'] Input form element value.
* string $values[]['id'] Input form element id attribute.
* string $values[]['on_change'] Javascript handler for onchange event.
* @property array
*/
protected $values = [];
public function __construct($name, $value) {
parent::__construct();
$this->name = $name;
$this->value = $value;
$this->orientation = self::ORIENTATION_HORIZONTAL;
$this->enabled = true;
$this->values = [];
$this->modern = false;
$this->readonly = false;
$this->setId(zbx_formatDomId($name));
}
public function setValues(array $values): self {
foreach ($values as $value) {
$this->addValue($value['name'], $value['value'], $value['id'] ?? null, $value['on_change'] ?? null);
}