_columns = []; return $this; } public function setColumns(array $columns) { $this->clearColumns(); $this->addColumns($columns); return $this; } public function addColumns(array $columns) { foreach ($columns as $name => $options) { $this->addColumn($name, $options); } return $this; } public function addColumn($name, array $options) { if (!isset($options['type'])) { throw new Qs_Form_Element_Exception('Type is undefined for column "' . $name . '"'); } if (!in_array($options['type'], $this->_columnTypes)) { throw new Qs_Form_Element_Exception('Type "' . $options['type'] . '" is not registered'); } $this->_columns[$name] = $options; return $this; } public function getColumns() { return $this->_columns; } public function setSortable($flag = true) { $this->_sortable = (bool) $flag; return $this; } public function isSortable() { return $this->_sortable; } public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('Grid') ->addDecorator('Errors') ->addDecorator('Description', ['tag' => 'p', 'class' => 'description']) ->addDecorator('HtmlTag', ['tag' => 'dd', 'id' => $this->getName() . '-element']) ->addDecorator('Label', ['tag' => 'dt']); } } public function getSourceElements() { return $this->_sourceElements; } public function getSourceElement($name) { if (isset($this->_sourceElements[$name])) { return $this->_sourceElements[$name]; } return null; } public function addColumnSourceElement($columnName, $elementType, $helperArguments) { if (!isset($this->_columns[$columnName])) { throw new Qs_Form_Element_Exception('Column "' . $columnName . '" not found'); } $elementName = current($helperArguments); $this->_columns[$columnName]['valueFrom'] = $elementName; $helperArguments[0] = str_replace('[]', '[' . $elementName . ']', $this->getFullyQualifiedName()); $this->_sourceElements[$elementName] = ['type' => $elementType, 'arguments' => $helperArguments]; return $this; } protected function _getErrorMessages() { $translator = $this->getTranslator(); $messages = $this->getErrorMessages(); $value = $this->getValue(); foreach ($messages as $key => &$message) { if (null !== $translator) { $message = $translator->translate($message); } } return $messages; } }