Exemplo n.º 1
0
 /**
  * Returns the fieldset opening tag and legend tag, if legend is defined
  * @param FieldsetInterface $fieldset
  * @param string|null $formType
  * @param array $displayOptions
  * @return string
  */
 public function openTag(FieldsetInterface $fieldset, $formType = null, array $displayOptions = array())
 {
     $formType = $this->formUtil->filterFormType($formType);
     $class = $fieldset->getAttribute('class');
     if (array_key_exists('class', $displayOptions)) {
         $class = $this->genUtil->addWords($displayOptions['class'], $class);
     }
     $escapeHtmlAttrHelper = $this->getEscapeHtmlAttrHelper();
     $class = $this->genUtil->escapeWords($class, $escapeHtmlAttrHelper);
     $fieldset->setAttribute('class', $class);
     if ($class) {
         $classAttrib = sprintf(' class="%s"', $class);
     } else {
         $classAttrib = '';
     }
     $html = sprintf('<fieldset%s>', $classAttrib);
     $legend = $fieldset->getOption('legend');
     if ($legend && (!array_key_exists('display_legend', $displayOptions) || $displayOptions['display_legend']) && ($formType == FormUtil::FORM_TYPE_HORIZONTAL || $formType == FormUtil::FORM_TYPE_VERTICAL)) {
         //Translate
         if (null !== ($translator = $this->getTranslator())) {
             $legend = $translator->translate($legend, $this->getTranslatorTextDomain());
         }
         //Escape
         $escapeHelper = $this->getEscapeHtmlHelper();
         $legend = $escapeHelper($legend);
         $html .= "<legend>{$legend}</legend>";
     }
     return $html;
 }
Exemplo n.º 2
0
 /**
  * 
  * @param \Zend\Form\FieldsetInterface $element
  * @return string
  */
 public function render(FieldsetInterface $element)
 {
     $formCollection = $this->getRenderer()->plugin('formCollection');
     $formCollection->setShouldWrap(false);
     $element->setAttribute('id', $element->getAttribute('name') . '-fieldset');
     $attributeHelper = new Attributes();
     $attributes = $attributeHelper->render($element, array('name'));
     $html = '<fieldset ' . $attributes . '>';
     $label = $element->getLabel();
     if ($label) {
         $html .= '<legend>' . $label . '</legend>';
     }
     $html .= $formCollection->render($element);
     $html .= '</fieldset>';
     return $html;
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function getAttribute($key)
 {
     return $this->element->getAttribute($key);
 }