field = $field; } public function getLabel(): ?CLabel { $label = parent::getLabel(); if ($label !== null) { $label->setFor($this->getSelect()->getFocusableElementId()); } return $label; } public function getView(): CSelect { return $this->getSelect(); } public function getJavaScript(): string { return ' var filter_select = document.getElementById("'.$this->field->getName().'"); filter_select.addOption('.json_encode(['label' => _('Select widget'), 'value' => '-1']).'); filter_select.selectedIndex = 0; ZABBIX.Dashboard.getSelectedDashboardPage().getWidgets().forEach((widget) => { if (widget.getType() === "'.$this->field->getSearchByValue().'") { const widget_reference = widget.getFields().reference; filter_select.addOption({label: widget.getHeaderName(), value: widget_reference}); if (widget_reference === "'.$this->field->getValue().'") { filter_select.value = "'.$this->field->getValue().'"; } } }); '; } private function getSelect(): CSelect { if ($this->select === null) { $this->select = (new CSelect($this->field->getName())) ->setId($this->field->getName()) ->setFocusableElementId('label-'.$this->field->getName()) ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) ->setAriaRequired($this->isRequired()); } return $this->select; } }