Source
$legend_lines_mode_field = $form->registerField(new CWidgetFieldRadioButtonListView($fields['legend_lines_mode']));
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2024 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/>.
**/
/**
* Pie chart widget form view.
*
* @var CView $this
* @var array $data
*/
use Widgets\PieChart\Includes\{
CWidgetFieldDataSet,
CWidgetFieldDataSetView
};
$form = new CWidgetFormView($data);
$form_tabs = (new CTabView())
->addTab('data_set', _('Data set'), getDatasetTab($form, $data['fields']),
'pie-dataset'
)
->addTab('displaying_options', _('Displaying options'), getDisplayOptionsTab($form, $data['fields']),
'pie-display-options'
)
->addTab('time_period', _('Time period'), getTimePeriodTab($form, $data['fields']),
'pie-time-period'
)
->addTab('legend_tab', _('Legend'), getLegendTab($form, $data['fields']),
'pie-legend'
)
->setSelected(0)
->addClass('pie-chart-widget-config-tabs');
$form
->addItem($form_tabs)
->addJavaScript($form_tabs->makeJavascript())
->includeJsFile('widget.edit.js.php')
->addJavaScript('widget_pie_chart_form.init('.json_encode([
'form_tabs_id' => $form_tabs->getId(),
'color_palette' => CWidgetFieldDataSet::DEFAULT_COLOR_PALETTE,
'templateid' => $data['templateid']
], JSON_THROW_ON_ERROR).');')
->show();
function getDatasetTab(CWidgetFormView $form, array $fields): array {
$dataset_field = $form->registerField(new CWidgetFieldDataSetView($fields['ds']));
return [
(new CDiv($dataset_field->getView()))->addClass(ZBX_STYLE_LIST_VERTICAL_ACCORDION),
(new CDiv($dataset_field->getFooterView()))->addClass(ZBX_STYLE_LIST_ACCORDION_FOOT)