Source
(new CCheckBox('status', ZBX_AUTH_TOKEN_ENABLED))->setChecked($data['status'] == ZBX_AUTH_TOKEN_ENABLED)
<?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/>.
**/
/**
* @var CView $this
* @var array $data
*/
$url = (new CUrl('zabbix.php'))
->setArgument('action', ($data['tokenid'] == 0) ? 'token.create' : 'token.update')
->getUrl();
$token_form = (new CForm('post', $url))
->addItem((new CVar(CSRF_TOKEN_NAME, CCsrfTokenHelper::get('token')))->removeId())
->setId('token_form')
->setName('token')
->addVar('admin_mode', $data['admin_mode'])
->addVar('tokenid', $data['tokenid']);
// Enable form submitting on Enter.
$token_form->addItem((new CSubmitButton())->addClass(ZBX_STYLE_FORM_SUBMIT_HIDDEN));
if ($data['admin_mode'] === '0') {
$token_form->addVar('userid', CWebUser::$data['userid']);
}
$token_from_grid = (new CFormGrid())->addItem([
(new CLabel(_('Name'), 'name'))->setAsteriskMark(),
new CFormField(
(new CTextBox('name', $data['name'], false, DB::getFieldLength('token', 'name')))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setAttribute('autofocus', 'autofocus')
->setAriaRequired()
)
]);
if ($data['admin_mode'] === '1') {
$token_from_grid->addItem([
(new CLabel(_('User'), 'userid_ms'))->setAsteriskMark(),
new CFormField(
(new CMultiSelect([
'readonly' => ($data['tokenid'] != 0),
'multiple' => false,
'name' => 'userid',
'object_name' => 'users',
'data' => $data['ms_user'],
'placeholder' => '',
'popup' => [
'parameters' => [
'srctbl' => 'users',