addClass(self::ZBX_STYLE_CLASS) ->setId(zbx_formatDomId($name)) ->setAttribute('data-name', $name); $this->name = $name; $this->value = $value; $this->options = $options; } /** * @param string $value * * @return CMultilineInput */ public function setValue($value) { $this->value = $value; return $this; } /** * @param string $key * @param string|int|bool $value * * @return CMultilineInput */ public function setOption($key, $value) { $this->options[$key] = $value; return $this; } /** * @return CMultilineInput */ public function setEnabled() { $this->options['disabled'] = false; return $this; } /** * @return CMultilineInput */ public function setDisabled() { $this->options['disabled'] = true; return $this; } /** * Get content of all Javascript code. * * @return string Javascript code. */ public function getPostJS() { return 'jQuery("#'.$this->getId().'").multilineInput('.json_encode([ 'value' => $this->value ] + $this->options).');'; } public function toString($destroy = true) { if (!array_key_exists('add_post_js', $this->options) || $this->options['add_post_js']) { zbx_add_post_js($this->getPostJS()); } return parent::toString($destroy); } }