Source
<?php declare(strict_types = 0);
/*
** 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/>.
**/
namespace Widgets\Clock\Includes;
use Zabbix\Widgets\{
CWidgetField,
CWidgetForm
};
use Zabbix\Widgets\Fields\{
CWidgetFieldCheckBox,
CWidgetFieldCheckBoxList,
CWidgetFieldColor,
CWidgetFieldIntegerBox,
CWidgetFieldMultiSelectItem,
CWidgetFieldMultiSelectOverrideHost,
CWidgetFieldRadioButtonList,
CWidgetFieldSelect,
CWidgetFieldTimeZone
};
use Widgets\Clock\Widget;
/**
* Clock widget form.
*/
class WidgetForm extends CWidgetForm {
private const SIZE_PERCENT_MIN = 1;
private const SIZE_PERCENT_MAX = 100;
private const DEFAULT_DATE_SIZE = 20;
public const DEFAULT_TIME_SIZE = 30;
private const DEFAULT_TIMEZONE_SIZE = 20;
public function validate(bool $strict = false): array {
$errors = parent::validate($strict);
if ($errors) {
return $errors;
}
if ($this->getFieldValue('time_type') == TIME_TYPE_HOST && !$this->getFieldValue('itemid')) {
$errors[] = _s('Invalid parameter "%1$s": %2$s.', _('Item'), _('cannot be empty'));
}
if ($this->getFieldValue('clock_type') == Widget::TYPE_DIGITAL && !$this->getFieldValue('show')) {
$errors[] = _s('Invalid parameter "%1$s": %2$s.', _('Show'), _('at least one option must be selected'));
}