Source
foreach ($time_period_field_view->getViewCollection() as ['label' => $label, 'view' => $view, 'class' => $class]) {
<?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/>.
**/
/**
* @var CView $this
* @var array $data
*/
use Zabbix\Widgets\Fields\CWidgetFieldColumnsList;
$form = (new CForm())
->setName('tophosts_column')
->addStyle('display: none;')
->addVar('action', $data['action'])
->addVar('update', 1);
// Enable form submitting on Enter.
$form->addItem((new CSubmitButton())->addClass(ZBX_STYLE_FORM_SUBMIT_HIDDEN));
$form_grid = new CFormGrid();
$scripts = [];
if (array_key_exists('edit', $data)) {
$form->addVar('edit', 1);
}
// Name.
$form_grid->addItem([
(new CLabel(_('Name'), 'column_name'))->setAsteriskMark(),
new CFormField(
(new CTextBox('name', $data['name'], false))
->setId('column_name')
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setAttribute('autofocus', 'autofocus')
->setAriaRequired()
)
]);
// Data.
$form_grid->addItem([
new CLabel(_('Data'), 'data'),
new CFormField(
(new CSelect('data'))
->setValue($data['data'])
->addOptions(CSelect::createOptionsFromArray([
CWidgetFieldColumnsList::DATA_ITEM_VALUE => _('Item value'),
CWidgetFieldColumnsList::DATA_HOST_NAME => _('Host name'),
CWidgetFieldColumnsList::DATA_TEXT => _('Text')
]))