コード例 #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;
 }
コード例 #2
0
ファイル: FormCollection.php プロジェクト: coolms/common
 /**
  * @return null|string
  */
 public function getPartial(FieldsetInterface $element = null)
 {
     $renderer = $this->getView();
     if ($element && true === $this->partial && method_exists($renderer, 'resolver') && ($partial = $element->getOption('partial'))) {
         $class = new ReflectionClass($renderer);
         if ($class->hasMethod('getTemplate')) {
             $template = $renderer->getTemplate();
         } elseif ($class->hasProperty('__template')) {
             $property = $class->getProperty('__template');
             $property->setAccessible(true);
             $template = $property->getValue($renderer);
         } else {
             return;
         }
         if (is_string($partial) && is_string($template) && realpath($renderer->resolver($partial)) === realpath($renderer->resolver($template))) {
             return;
         }
         return $partial;
     }
     if (is_string($this->partial)) {
         return $this->partial;
     }
 }