/** * Add cell by specifying column key and value * * @param string $columnKey * @param string|HtmlElement $value * @return HtmlElement * @throws Exception */ public function addCell($columnKey, $value = null) { if ($this->existsCell($columnKey)) { throw new Exception('cell "' . $columnKey . '" already exists.'); } $cell = new HtmlElement($this->_cellTagName); $cell->setIsReturnInner(false); $attrs = $this->_parentTable->getColumnAttributes($columnKey); if ($attrs) { $cell->setAttributes($attrs); } if ($value !== null) { $nodes = $value; if (!is_array($value)) { $nodes = array($value); } $cell->addNodes($nodes); } $this->_addCellElement($columnKey, $cell); return $cell; }
/** * Create and return element of input tags whose type are checkbox * * @param string $name * @param array $list * @param string $defaultValue * @param array $attributes * @return FormElementSet */ public function createCheckboxes($name = null, $list = array(), $defaultValue = null, $attributes = null) { $this->_checkArgumentIsArray(__METHOD__, 2, $list); $frame = $this->createFormElementSet('span'); if (!is_array($attributes)) { $attributes = array(); } $attributes['type'] = 'checkbox'; if (is_array($list)) { foreach ($list as $value => $text) { $checkbox = new FormElement('input'); $checkbox->setIsReturnInner(false); $checkbox->setAttributes($attributes); $checkbox->setValue($value); $label = new HtmlElement('label'); $label->setIsReturnInner(false); $label->addElement($checkbox); $label->addNode($text); $frame->addElement($label); } } $frame->setName($name); if ($defaultValue !== null) { $frame->setValue($defaultValue); } return $frame; }