当前位置: 首页>>代码示例>>PHP>>正文


PHP ElementInterface::getEmptySummaryNotice方法代码示例

本文整理汇总了PHP中Zend\Form\ElementInterface::getEmptySummaryNotice方法的典型用法代码示例。如果您正苦于以下问题:PHP ElementInterface::getEmptySummaryNotice方法的具体用法?PHP ElementInterface::getEmptySummaryNotice怎么用?PHP ElementInterface::getEmptySummaryNotice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Form\ElementInterface的用法示例。


在下文中一共展示了ElementInterface::getEmptySummaryNotice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderSummaryElement

 /**
  * Helper function to recurse into form elements when rendering summary.
  * 
  * @param ElementInterface $element
  * @return string
  */
 protected function renderSummaryElement(ElementInterface $element)
 {
     if ($element instanceof Hidden || false === $element->getOption('render_summary')) {
         return '';
     }
     if ($element instanceof ViewPartialProviderInterface) {
         $partial = $element->getViewPartial();
         $summaryPartial = $partial . '.summary';
         $partialParams = array('element' => $element);
         if (!$this->getView()->resolver($summaryPartial)) {
             $summaryPartial = $partial;
             $partialParams['renderSummary'] = true;
         }
         return $this->getView()->partial($summaryPartial, $partialParams);
     }
     if ($element instanceof EmptySummaryAwareInterface && $element->isSummaryEmpty()) {
         $emptySummaryNotice = $this->getTranslator()->translate($element->getEmptySummaryNotice(), $this->getTranslatorTextDomain());
         $markup = sprintf('<div id="%s-empty-alert" class="empty-summary-notice alert alert-info"><p>%s</p></div>', $element->getAttribute('id'), $emptySummaryNotice);
         return $markup;
     }
     $label = $element->getLabel();
     $markup = '';
     if ($element instanceof FieldsetInterface) {
         if (!$element instanceof FormInterface && $label) {
             $markup .= '<h4>' . $label . '</h4>';
         }
         foreach ($element as $el) {
             $markup .= $this->renderSummaryElement($el);
         }
         return $markup;
     }
     $elementValue = $element instanceof \Zend\Form\Element\Textarea ? nl2br($element->getValue()) : $element->getValue();
     $markup .= '<div class="row">';
     $col = 12;
     if ($label) {
         $markup .= '<div class="col-md-3"><strong>' . $label . '</strong></div>';
         $col = 9;
     }
     $markup .= '<div class="col-md-' . $col . '">' . $elementValue . '</div>' . '</div>';
     return $markup;
 }
开发者ID:bitrecruiter,项目名称:CrossApplicantManager,代码行数:47,代码来源:SummaryForm.php

示例2: renderSummaryElement

 /**
  * Helper function to recurse into form elements when rendering summary.
  *
  * @param ElementInterface $element
  * @return string
  */
 protected function renderSummaryElement(ElementInterface $element)
 {
     if ($element instanceof Hidden || false === $element->getOption('render_summary')) {
         return '';
     }
     if ($element instanceof ViewPartialProviderInterface) {
         $renderer = $this->getView();
         /* @var $renderer \Zend\View\Renderer\PhpRenderer */
         $origPartial = $element->getViewPartial();
         $partial = "{$origPartial}.view";
         $partialParams = array('element' => $element);
         if (!$renderer->resolver($partial)) {
             $partial = $origPartial;
             $partialParams['renderSummary'] = true;
         }
         return $renderer->partial($partial, $partialParams);
     }
     if ($element instanceof EmptySummaryAwareInterface && $element->isSummaryEmpty()) {
         /* @var $element EmptySummaryAwareInterface|ElementInterface */
         $emptySummaryNotice = $this->getTranslator()->translate($element->getEmptySummaryNotice(), $this->getTranslatorTextDomain());
         $markup = sprintf('<div id="%s-empty-alert" class="empty-summary-notice alert alert-info"><p>%s</p></div>', $element->getAttribute('id'), $emptySummaryNotice);
         return $markup;
     }
     $label = $this->getTranslator()->translate($element->getLabel());
     $markup = '';
     if ($element instanceof FieldsetInterface) {
         if (!$element instanceof FormInterface && $label) {
             $markup .= '<h4>' . $label . '</h4>';
         }
         foreach ($element as $el) {
             $markup .= $this->renderSummaryElement($el);
         }
         return $markup;
     }
     $elementValue = $element instanceof \Zend\Form\Element\Textarea ? nl2br($element->getValue()) : $element->getValue();
     if ('' != $elementValue && $element instanceof \Zend\Form\Element\Select) {
         $options = $element->getValueOptions();
         $translator = $this->getTranslator();
         if (true == $element->getAttribute('multiple')) {
             $multiOptions = [];
             foreach ($elementValue as $optionKey) {
                 if (isset($options[$optionKey])) {
                     $multiOptions['__general__'][] = $translator->translate($options[$optionKey]);
                     continue;
                 }
                 foreach ($options as $optKey => $optVal) {
                     if (!is_array($optVal) || !array_key_exists($optionKey, $optVal['options'])) {
                         continue;
                     }
                     $optGroupLabel = isset($optVal['label']) ? $translator->translate($optVal['label']) : $optKey;
                     $multiOptions[$optGroupLabel][] = $translator->translate($optVal['options'][$optionKey]);
                 }
             }
             $elementValue = [];
             foreach ($multiOptions as $optGroupLabel => $vals) {
                 $elementValue[] = "<b>{$optGroupLabel}</b><br>" . join(', ', $vals);
             }
             $elementValue = join('<br>', $elementValue) . '<br>';
         } else {
             $elementValue = $translator->translate($options[$elementValue]);
         }
     }
     if ('' != $elementValue && $element instanceof \Zend\Form\Element\File) {
         return '';
     }
     $markup .= '<div class="row">';
     $col = 12;
     if ($label) {
         $markup .= '<div class="col-md-3 yk-label"><label>' . $label . '</label></div>';
         $col = 9;
     }
     $markup .= '<div class="col-md-' . $col . '">' . $elementValue . '</div>' . '</div>';
     return $markup;
 }
开发者ID:utrenkner,项目名称:YAWIK,代码行数:80,代码来源:SummaryForm.php


注:本文中的Zend\Form\ElementInterface::getEmptySummaryNotice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。