/** * Renders an element, along with its label. * * @param \Brick\Form\Element $element * * @return string */ private function renderElementAsRow(Element $element) { $tr = new Tag('tr'); $html = $this->renderCell('th', $element->getLabel()->render() . $this->renderErrors($element)); $html .= $this->renderCell('td', $element->render()); $tr->setHtmlContent($html); return $tr->render(); }
/** * Renders an element, along with its label. * * @param \Brick\Form\Element $element * @return string */ private function renderElement(Element $element) { $label = $element->getLabel(); if ($label->isEmpty()) { return $element->render(); } return $label->render() . $element->render(); }
/** * @param Element $element * * @return string */ public function generateElementId(Element $element) { preg_match('/^([a-zA-Z0-9]*)/', $element->getName(), $matches); $name = $matches[0]; if (!isset($this->ids[$name])) { $this->ids[$name] = 0; } return $this->getId() . '-' . $name . '-' . $this->ids[$name]++; }
/** * Renders the label. * * @return string */ public function render() { return $this->tag->setAttribute('for', $this->element->getId())->render(); }