2 /* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
3 and is published under the AGPL license. */
5 require_once 'Zend/Form/Decorator/Description.php';
6 require_once 'Zend/Form/Decorator/HtmlTag.php';
9 * wraps description content in a <td> tag then in a <tr> tag
11 class Syj_Form_Decorator_TableDescription extends Zend_Form_Decorator_Description
14 public function getClass()
16 $class = $this->getOption('class');
17 if (null === $class) {
19 $this->setOption('class', $class);
25 public function render($content)
27 $element = $this->getElement();
28 $view = $element->getView();
33 $description = $element->getDescription();
34 $description = trim($description);
36 if (!empty($description) && (null !== ($translator = $element->getTranslator()))) {
37 $description = $translator->translate($description);
40 if (empty($description)) {
44 $separator = $this->getSeparator();
45 $placement = $this->getPlacement();
46 $class = $this->getClass();
47 $escape = $this->getEscape();
49 $options = $this->getOptions();
52 $description = $view->escape($description);
55 $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'div',
56 'id' => $this->getElement()->getName() . '-desc',
58 $description = $decorator->render($description);
59 $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'td'));
60 $description = $decorator->render($description);
61 $description = '<td> </td>' . $description;
62 $decorator = new Zend_Form_Decorator_HtmlTag(array('tag' => 'tr'));
63 $description = $decorator->render($description);
67 return $description . $separator . $content;
70 return $content . $separator . $description;