Example #1
0
 /**
  * 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();
 }
Example #2
0
 /**
  * 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();
 }
Example #3
0
File: Form.php Project: brick/form
 /**
  * @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]++;
 }
Example #4
0
File: Label.php Project: brick/form
 /**
  * Renders the label.
  *
  * @return string
  */
 public function render()
 {
     return $this->tag->setAttribute('for', $this->element->getId())->render();
 }