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


PHP ElementInterface::getIterator方法代码示例

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


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

示例1: render

 /**
  * Render a collection by iterating through all fieldsets and elements
  * @param \Zend\Form\ElementInterface $oElement
  * @return string
  */
 public function render(ElementInterface $oElement)
 {
     $oRenderer = $this->getView();
     if (!method_exists($oRenderer, 'plugin')) {
         return '';
     }
     $bShouldWrap = $this->shouldWrap;
     $sMarkup = '';
     $sElementLayout = $oElement->getOption('bootstrap-layout');
     if ($oElement instanceof \IteratorAggregate) {
         $oElementHelper = $this->getElementHelper();
         $oFieldsetHelper = $this->getFieldsetHelper();
         foreach ($oElement->getIterator() as $oElementOrFieldset) {
             $aOptions = $oElementOrFieldset->getOptions();
             if ($sElementLayout && empty($aOptions['bootstrap-layout'])) {
                 $aOptions['bootstrap-layout'] = $sElementLayout;
                 $oElementOrFieldset->setOptions($aOptions);
             }
             if ($oElementOrFieldset instanceof \Zend\Form\FieldsetInterface) {
                 $sMarkup .= $oFieldsetHelper($oElementOrFieldset);
             } elseif ($oElementOrFieldset instanceof \Zend\Form\ElementInterface) {
                 if ($oElementOrFieldset->getOption('bootstrap-row-open')) {
                     $sMarkup .= '<div class="row">' . PHP_EOL;
                 }
                 $sMarkup .= $oElementHelper($oElementOrFieldset);
                 if ($oElementOrFieldset->getOption('bootstrap-row-close')) {
                     $sMarkup .= '</div>' . PHP_EOL;
                 }
             }
         }
         if ($oElement instanceof \Zend\Form\Element\Collection && $oElement->shouldCreateTemplate()) {
             $sMarkup .= $this->renderTemplate($oElement);
         }
     }
     if ($bShouldWrap) {
         if (false != ($sLabel = $oElement->getLabel())) {
             if (null !== ($oTranslator = $this->getTranslator())) {
                 $sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
             }
             $sMarkup = sprintf(self::$legendFormat, ($sAttributes = $this->createAttributesString($oElement->getLabelAttributes() ?: array())) ? ' ' . $sAttributes : '', $this->getEscapeHtmlHelper()->__invoke($sLabel)) . $sMarkup;
         }
         //Set form layout class
         if ($sElementLayout) {
             $sLayoutClass = 'form-' . $sElementLayout;
             if (false != ($sElementClass = $oElement->getAttribute('class'))) {
                 if (!preg_match('/(\\s|^)' . preg_quote($sLayoutClass, '/') . '(\\s|$)/', $sElementClass)) {
                     $oElement->setAttribute('class', trim($sElementClass . ' ' . $sLayoutClass));
                 }
             } else {
                 $oElement->setAttribute('class', $sLayoutClass);
             }
         }
         $sMarkup = sprintf(self::$fieldsetFormat, ($sAttributes = $this->createAttributesString($oElement->getAttributes())) ? ' ' . $sAttributes : '', $sMarkup);
     }
     return $sMarkup;
 }
开发者ID:cityware,项目名称:city-bootstrap,代码行数:61,代码来源:BootstrapFormCollection.php

示例2: render

 public function render(\Zend\Form\ElementInterface $oElement)
 {
     if ($oElement->getOption('value_only') === true && $oElement instanceof \IteratorAggregate) {
         foreach ($oElement->getIterator() as $oElementOrFieldset) {
             $oElementOrFieldset->setOption('value_only', true);
             if ($oElement->getOption('add_hidden')) {
                 $oElementOrFieldset->setOption('add_hidden', true);
             }
         }
     }
     return parent::render($oElement);
 }
开发者ID:xelax90,项目名称:xelax-twb-unmask,代码行数:12,代码来源:FormCollection.php

示例3: render

 public function render(ElementInterface $element, $allowRemove = false)
 {
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         // Bail early if renderer is not pluggable
         return '';
     }
     $markup = '';
     $addButton = '';
     $removeButton = '';
     $escapeHtmlHelper = $this->getEscapeHtmlHelper();
     $elementHelper = $this->getElementHelper();
     $fieldsetHelper = $this->getFieldsetHelper();
     foreach ($element->getIterator() as $elementOrFieldset) {
         if ($elementOrFieldset instanceof FieldsetInterface) {
             if ($fieldsetHelper instanceof $this && $element instanceof Collection) {
                 $markup .= $fieldsetHelper($elementOrFieldset, $element->allowRemove());
             } else {
                 $markup .= $fieldsetHelper($elementOrFieldset);
             }
         } elseif ($elementOrFieldset instanceof ElementInterface) {
             $markup .= $elementHelper($elementOrFieldset);
         }
     }
     // If $templateMarkup is not empty, use it for simplify adding new element in JavaScript
     if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
         $markup .= $this->renderTemplate($element);
         if ($element->allowAdd()) {
             $addButton = '<button onclick="' . str_replace('__placeholder__', $element->getTemplatePlaceholder(), $this->addButtonEvent) . '" type="button" class="close"><i class="glyphicon glyphicon-plus"></i></button>';
         }
     } elseif ($element instanceof Fieldset && $allowRemove) {
         $removeButton = sprintf($this->removeButtonMarkup, $this->removeButtonEvent, $this->removeButtonContent);
     }
     $label = $element->getLabel();
     if (!empty($label)) {
         if (null !== ($translator = $this->getTranslator())) {
             $label = $translator->translate($label, $this->getTranslatorTextDomain());
         }
         $label = $escapeHtmlHelper($label);
         $label = sprintf('<legend>%s%s%s</legend>', $label, $removeButton, $addButton);
         $wrapper = $label;
     } else {
         $wrapper = sprintf('<div class="collection-header">%s%s</div>', $removeButton, $addButton);
     }
     $markup = sprintf('<fieldset>%s%s</fieldset>', $wrapper, $markup);
     return $markup;
 }
开发者ID:skpd,项目名称:bootstrap,代码行数:47,代码来源:FormCollection.php

示例4: render

 /**
  * Render a collection by iterating through all fieldsets and elements
  *
  * @param  ElementInterface $element
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         // Bail early if renderer is not pluggable
         return '';
     }
     $markup = '';
     $templateMarkup = '';
     $escapeHtmlHelper = $this->getEscapeHtmlHelper();
     $rowHelper = $this->getRowHelper();
     if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
         $elementOrFieldset = $element->getTemplateElement();
         if ($elementOrFieldset instanceof FieldsetInterface) {
             $templateMarkup .= $this->render($elementOrFieldset);
         } elseif ($elementOrFieldset instanceof ElementInterface) {
             $templateMarkup .= $rowHelper($elementOrFieldset);
         }
     }
     foreach ($element->getIterator() as $elementOrFieldset) {
         if ($elementOrFieldset instanceof FieldsetInterface) {
             $markup .= $this->render($elementOrFieldset);
         } elseif ($elementOrFieldset instanceof ElementInterface) {
             $markup .= $rowHelper($elementOrFieldset);
         }
     }
     // If $templateMarkup is not empty, use it for simplify adding new element in JavaScript
     if (!empty($templateMarkup)) {
         $escapeHtmlAttribHelper = $this->getEscapeHtmlAttrHelper();
         $markup .= sprintf('<span data-template="%s"></span>', $escapeHtmlAttribHelper($templateMarkup));
     }
     // Every collection is wrapped by a fieldset if needed
     if ($this->shouldWrap) {
         $label = $element->getLabel();
         if (!empty($label)) {
             $label = $escapeHtmlHelper($label);
             $markup = sprintf('<fieldset><legend>%s</legend>%s</fieldset>', $label, $markup);
         }
     }
     return $markup;
 }
开发者ID:navassouza,项目名称:zf2,代码行数:47,代码来源:FormCollection.php

示例5: __invoke

 /**
  * @inheritdoc
  */
 public function __invoke(ElementInterface $fieldset = null, $labelPosition = null)
 {
     if (!$fieldset) {
         return $this;
     }
     $wrapper = '';
     if ($this->count === 1) {
         $wrapper .= ' <div class="row">';
     }
     $label = '<h2>' . $fieldset->getName() . '</h2>';
     $wrapper .= '<div class="col-md-' . $this->columnWidth . '">' . $label . '%s</div>';
     if ($this->count === 6) {
         $wrapper .= '</div>';
         $this->count = 0;
     }
     $this->count = $this->count + 1;
     $content = '';
     foreach ($fieldset->getIterator() as $item) {
         $content .= $this->getView()->formRow($item);
     }
     return sprintf($wrapper, $content);
 }
开发者ID:HPUinternet,项目名称:zf2-doctrine-datagrid,代码行数:25,代码来源:NestedSettings.php

示例6: render

 /**
  * Render a fieldset by iterating through all fieldsets and elements
  *
  * @param  ElementInterface $element
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         // Bail early if renderer is not pluggable
         return '';
     }
     $markup = '';
     $escapeHtmlHelper = $this->getEscapeHtmlHelper();
     $rowHelper = $this->getRowHelper();
     foreach ($element->getIterator() as $elementOrFieldset) {
         if ($elementOrFieldset instanceof FieldsetInterface) {
             $markup .= $this->render($elementOrFieldset);
         } elseif ($elementOrFieldset instanceof ElementInterface) {
             $markup .= $rowHelper($elementOrFieldset);
         }
     }
     // Every collection is wrapped by a fieldset if needed
     if ($this->shouldWrap) {
         $label = $element->getLabel();
         if (!empty($label)) {
             $label = $escapeHtmlHelper($label);
             $markup = sprintf('<fieldset><legend>%s</legend>%s</fieldset>', $label, $markup);
         }
     }
     return $markup;
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:33,代码来源:FormFieldset.php


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