<?php declare(strict_types = 0);
->addItem((new CVar(CSRF_TOKEN_NAME, CCsrfTokenHelper::get('template')))->removeId())
->setId('templates-form')
->setName('template-edit-form')
->addItem((new CSubmitButton())->addClass(ZBX_STYLE_FORM_SUBMIT_HIDDEN))
->addVar('clone_templateid', $data['clone_templateid'] ?? null)
->addVar('clone', $data['clone'] ?: null);
$template_tab = (new CFormGrid())
(new CLabel(_('Template name'), 'template_name'))->setAsteriskMark(),
(new CTextBox('template_name', $data['template_name'], false, DB::getFieldLength('hosts', 'host')))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
->setAttribute('autofocus', 'autofocus')
new CLabel(_('Visible name'), 'visiblename'),
(new CTextBox('visiblename', $data['visible_name'], false, DB::getFieldLength('hosts', 'name')))
->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)
$templates_field_items = [];
if ($data['linked_templates']) {
$linked_templates= (new CTable())
->setHeader([_('Name'), _('Action')])
->setId('linked-templates')
->addClass(ZBX_STYLE_TABLE_FORMS)
->addStyle('width: '.ZBX_TEXTAREA_STANDARD_WIDTH.'px;');
foreach ($data['linked_templates'] as $template) {
if (array_key_exists($template['templateid'], $data['writable_templates'])) {
$template_link = (new CLink($template['name']))
->addClass('js-edit-linked-template')
->setAttribute('data-templateid', $template['templateid']);
$template_link = new CSpan($template['name']);
$linked_templates->addRow([
$template_link->addClass(ZBX_STYLE_WORDWRAP),
(new CButtonLink(_('Unlink')))
->setAttribute('data-templateid', $template['templateid'])
(array_key_exists($template['templateid'], $data['original_templates']))
? (new CButtonLink(_('Unlink and clear')))
->setAttribute('data-templateid', $template['templateid'])
->addClass('js-unlink-and-clear')
->addItem((new CVar('templates['.$template['templateid'].']', $template['templateid']))->removeId())
->addClass(ZBX_STYLE_NOWRAP)
], null, 'conditions_'.$template['templateid']);
$templates_field_items[] = $linked_templates;
$templates_field_items[] = (new CMultiSelect([
'name' => 'template_add_templates[]',