Source
xxxxxxxxxx
$expression_form_list->addRow(new CLabel(_('Function'), $function_select->getFocusableElementId()), $function_select);
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/**
* @var CView $this
*/
// Create form.
$expression_form = (new CForm())
->cleanItems()
->setName('expression')
->addVar('action', 'popup.triggerexpr')
->addVar('dstfrm', $data['dstfrm'])
->addVar('dstfld1', $data['dstfld1'])
->addItem((new CVar('hostid', $data['hostid']))->removeId())
->addVar('groupid', $data['groupid'])
->addVar('function', $data['function'])
->addItem((new CInput('submit', 'submit'))
->addStyle('display: none;')
->removeId()
);
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' => 'items',
'srcfld1' => 'itemid',
'srcfld2' => 'name',
'dstfrm' => $expression_form->getName(),
'dstfld1' => 'itemid',
'dstfld2' => 'item_description',
'with_webitems' => '1',
'writeonly' => '1'
];
if ($data['hostid']) {
$popup_options['hostid'] = $data['hostid'];
}
if ($data['parent_discoveryid'] !== '') {
$popup_options['normal_only'] = '1';
}
if ($data['item_required']) {
$expression_form->addVar('itemid', $data['itemid']);
$item = [
(new CTextBox('item_description', $data['item_description'], true))
->setAriaRequired()
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH),
(new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN),
(new CButton('select', _('Select')))
->addClass(ZBX_STYLE_BTN_GREY)
->onClick('return PopUp("popup.generic", '.json_encode($popup_options).');')
];
if ($data['parent_discoveryid'] !== '') {
$item[] = (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN);
$item[] = (new CButton('select', _('Select prototype')))
->addClass(ZBX_STYLE_BTN_GREY)
->setAttribute('data-parent_discoveryid', $data['parent_discoveryid'])
->onClick('
PopUp("popup.generic", {
srctbl: "item_prototypes",
srcfld1: "itemid",
srcfld2: "name",
dstfrm: "'.$expression_form->getName().'",