field = $field; } public function setPlaceholder(string $placeholder): self { $this->placeholder = $placeholder; return $this; } public function getLabel(): ?CLabel { $label = parent::getLabel(); if ($label !== null) { $label->setFor(zbx_formatDomId($this->field->getName().'[]').'_ms'); } return $label; } public function getView(): CPatternSelect { return (new CPatternSelect([ 'name' => $this->field->getName().'[]', 'object_name' => 'hosts', 'data' => $this->field->getValue(), 'placeholder' => $this->placeholder, 'wildcard_allowed' => 1, 'popup' => [ 'parameters' => [ 'srctbl' => 'hosts', 'srcfld1' => 'hostid', 'dstfrm' => $this->form_name, 'dstfld1' => zbx_formatDomId($this->field->getName().'[]') ] ], 'add_post_js' => false ])) ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) ->setEnabled(!$this->isDisabled()) ->setAriaRequired($this->isRequired()); } public function getJavaScript(): string { $field_id = zbx_formatDomId($this->field->getName().'[]'); return 'jQuery("#'.$field_id.'").multiSelect(jQuery("#'.$field_id.'").data("params"));'; } }