/** * Select element. * * @param string $name Element name. * @param string|null $label Element label. * @param string|null $description Element description. * @param array $elementOptions Element value options. * @param mixed|null $value Element value. * @param array $options Element options. * @param array $attributes Element attributes. * * @return $this */ public function addSelect($name, $label = null, $description = null, $elementOptions = [], $value = null, array $options = [], array $attributes = []) { $element = new Form\Element\Select($name, $options, $attributes); if (!$label) { $label = ucfirst($name); } $element->setOption('label', $label)->setOption('description', $description)->setOption('elementOptions', $elementOptions)->setValue($value); $this->add($element); return $this; }
/** * Add column to grid with select filter. * * @param int $id Column id. * @param string $label Column label. * @param array $options Select options * @param array $params Column params. * * @return $this */ public function addSelectColumn($id, $label, array $options, array $params = []) { $this->_columns[$id] = $this->_getDefaultColumnParams($params, $label); if (!empty($this->_columns[$id][AbstractGrid::COLUMN_PARAM_FILTER])) { $element = new Select($id); foreach ($options as $key => $value) { $element->setOption($key, $value); } $this->_columns[$id][AbstractGrid::COLUMN_PARAM_FILTER] = $element; } return $this; }