Source
$expression_form_list->addRow(new CLabel(_('Function'), $function_select->getFocusableElementId()), $function_select);
<?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
*/
// Create form.
$expression_form = (new CForm())
->setName('expression')
->addVar('action', 'popup.triggerexpr')
->addVar('dstfrm', $data['dstfrm'])
->addVar('dstfld1', $data['dstfld1'])
->addVar('context', $data['context'])
->addItem((new CVar('hostid', $data['hostid']))->removeId())
->addVar('groupid', $data['groupid'])
->addVar('function', $data['function']);
// Enable form submitting on Enter.
$expression_form->addItem((new CSubmitButton())->addClass(ZBX_STYLE_FORM_SUBMIT_HIDDEN));
if ($data['parent_discoveryid'] !== '') {
$expression_form->addVar('parent_discoveryid', $data['parent_discoveryid']);
}
// Create form list.
$expression_form_list = new CFormList();
// Append item to form list.
$popup_options = [
'srctbl' => $data['context'] === 'host' ? 'items' : 'template_items',
'srcfld1' => 'itemid',
'srcfld2' => 'name',
'dstfrm' => $expression_form->getName(),
'dstfld1' => 'itemid',
'dstfld2' => 'item_description',
'writeonly' => '1',
'value_types' => [
ITEM_VALUE_TYPE_FLOAT,
ITEM_VALUE_TYPE_STR,
ITEM_VALUE_TYPE_LOG,
ITEM_VALUE_TYPE_UINT64,
ITEM_VALUE_TYPE_TEXT
]
];
if ($data['context'] === 'host') {
if ($data['hostid']) {
$popup_options['hostid'] = $data['hostid'];
}