label = $label; foreach ($fields as $field) { $this->addItem($field); } $this->addClass(CFormGrid::ZBX_STYLE_FIELDS_GROUP); } public function getFields(): array { return $this->fields; } public function addField(?CWidgetFieldView $field): self { return $this->addItem($field); } public function addItem($value): self { if ($value === null) { return $this; } if (is_string($value)) { $value = $this->encode($value, $this->getEncStrategy()); } $this->fields[] = $value; return $this; } public function getLabel(): CLabel { return (new CLabel([$this->label, $this->field_hint])) ->addClass(CFormGrid::ZBX_STYLE_FIELDS_GROUP_LABEL) ->addClass($this->label_class_list ? implode(' ', $this->label_class_list) : null); } public function setFieldHint(CTag $hint): self { $this->field_hint = $hint; return $this; } public function addLabelClass(?string $label_class): self { if ($label_class !== null) { $this->label_class_list[] = $label_class; } return $this; } public function addRowClass(?string $row_class): self { $this->addLabelClass($row_class); $this->addClass($row_class); return $this; } protected function bodyToString() { foreach ($this->fields as &$field) { if ($field instanceof CWidgetFieldView) { $field = [ $field->getLabel(), (new CFormField($field->getView()))->addClass($field->getClass()) ]; } } unset($field); return unpack_object($this->fields); } }