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


PHP ElementInterface::shouldCreateTemplate方法代码示例

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


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

示例1: 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();
     $elementHelper = $this->getElementHelper();
     $fieldsetHelper = $this->getFieldsetHelper();
     if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
         $templateMarkup = $this->renderTemplate($element);
     }
     foreach ($element->getIterator() as $elementOrFieldset) {
         if ($elementOrFieldset instanceof FieldsetInterface) {
             $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 (!empty($templateMarkup)) {
         $markup .= $templateMarkup;
     }
     // Every collection is wrapped by a fieldset if needed
     if ($this->shouldWrap) {
         //Esto fue lo que se modificó para que trabajara con <div> en vez de <fieldset> - wyanez
         $markup = sprintf('<div>%s</div>', $markup);
     }
     return $markup;
 }
开发者ID:Ellipizle,项目名称:ZF2DoctrineBase,代码行数:39,代码来源:MyFormCollection.php

示例2: 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

示例3: getControl

 /**
  * @param ElementInterface $element
  * @return string
  */
 protected function getControl(ElementInterface $element)
 {
     $btnHelper = $this->getView()->plugin('btn');
     $iconHelper = $this->getView()->plugin('icon');
     if ($element instanceof Collection && $element->allowAdd() && $element->shouldCreateTemplate()) {
         return $btnHelper($iconHelper('plus'), ['class' => 'btn-success pull-right clearfix', 'onclick' => "return CmsCommon.Form.Collection.addFieldset(this, 'prepend');"]);
     } elseif ($element instanceof FieldsetInterface && !$element instanceof Collection && $element->getOption('allow_remove')) {
         return $btnHelper($iconHelper('minus'), ['class' => 'btn-danger pull-right clearfix', 'onclick' => 'return CmsCommon.Form.Collection.removeFieldset(this);']);
     }
 }
开发者ID:coolms,项目名称:twbs,代码行数:14,代码来源:FormCollection.php

示例4: render

 /**
  * @inheritdoc
  */
 public function render(ElementInterface $element)
 {
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         // Bail early if renderer is not pluggable
         return '';
     }
     $markup = '';
     $templateMarkup = '';
     $elementHelper = $this->getElementHelper();
     $fieldsetHelper = $this->getFieldsetHelper();
     $wrapperClass = $element->getOption('wrapper_class');
     if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
         $templateMarkup = $this->renderTemplate($element);
     }
     foreach ($element->getIterator() as $elementOrFieldset) {
         if ($elementOrFieldset instanceof FieldsetInterface) {
             $markup .= $fieldsetHelper($elementOrFieldset, $this->shouldWrap());
         } elseif ($elementOrFieldset instanceof ElementInterface && is_callable($elementHelper)) {
             $markup .= $elementHelper($elementOrFieldset);
         }
     }
     if ($wrapperClass) {
         $markup = "<div class='{$wrapperClass}'>{$markup}</div>";
     }
     // Every collection is wrapped by a fieldset if needed
     if ($this->shouldWrap) {
         $attributes = $element->getAttributes();
         unset($attributes['name']);
         $attributesString = count($attributes) ? ' ' . $this->createAttributesString($attributes) : '';
         $label = $element->getLabel();
         $legend = '';
         if (!empty($label)) {
             if (null !== ($translator = $this->getTranslator())) {
                 $label = $translator->translate($label, $this->getTranslatorTextDomain());
             }
             if (!$element instanceof LabelAwareInterface || !$element->getLabelOption('disable_html_escape')) {
                 $escapeHtmlHelper = $this->getEscapeHtmlHelper();
                 $label = $escapeHtmlHelper($label);
             }
             $legend = sprintf($this->labelWrapper, $label);
         }
         $markup = sprintf($this->wrapper, $markup, $legend, $templateMarkup, $attributesString);
     } else {
         $markup .= $templateMarkup;
     }
     return $markup;
 }
开发者ID:kashandarash,项目名称:blog-example,代码行数:51,代码来源:FormCollection.php

示例5: 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

示例6: 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 '';
     }
     $attributes = $element->getAttributes();
     $markup = '';
     $templateMarkup = '';
     $escapeHtmlHelper = $this->getEscapeHtmlHelper();
     $elementHelper = $this->getElementHelper();
     $fieldsetHelper = $this->getFieldsetHelper();
     if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
         $templateMarkup = $this->renderTemplate($element);
     }
     foreach ($element->getIterator() as $elementOrFieldset) {
         if ($elementOrFieldset instanceof FieldsetInterface) {
             $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 (!empty($templateMarkup)) {
         $markup .= $templateMarkup;
     }
     // Every collection is wrapped by a fieldset if needed
     if ($this->shouldWrap) {
         $label = $element->getLabel();
         $legend = '';
         if (!empty($label)) {
             if (null !== ($translator = $this->getTranslator())) {
                 $label = $translator->translate($label, $this->getTranslatorTextDomain());
             }
             $label = $escapeHtmlHelper($label);
             $legend = sprintf('<legend>%s</legend>', $label);
         }
         $attributesString = $this->createAttributesString($attributes);
         if (!empty($attributesString)) {
             $attributesString = ' ' . $attributesString;
         }
         $markup = sprintf('<fieldset%s>%s%s</fieldset>', $attributesString, $legend, $markup);
     }
     return $markup;
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:52,代码来源:FormCollection.php

示例7: render

 /**
  * Render a collection by iterating through all fieldsets and elements
  *
  * @param ElementInterface $element
  * @param int              $index
  *
  * @return string
  *
  */
 public function render(ElementInterface $element, $index = 0)
 {
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         // Bail early if renderer is not pluggable
         return '';
     }
     $markup = '';
     if ($element instanceof CollectionElement) {
         $templateMarkup = "";
         if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
             $templateMarkup = $this->renderTemplate($element);
         }
         $match = $this->getMatch($element);
         if ($match == null) {
             $player1 = 'n/a';
             $player2 = 'n/a';
         } else {
             if ($match instanceof \Application\Model\Entity\DoubleMatch) {
                 $player1 = 'Team 1';
                 $player2 = 'Team 2';
             } else {
                 if ($match instanceof \Application\Model\Entity\SingleMatch) {
                     $player1 = $match->getPlayer1()->getName();
                     $player2 = $match->getPlayer2()->getName();
                 } else {
                     $player1 = "Foo";
                     $player2 = "Bar";
                 }
             }
         }
         $markup = '<table id="matchform"><tr><th></th><th>%s</th><th>vs.</th><th>%s</th></tr>';
         $markup = sprintf($markup, $player1, $player2);
         $index = 1;
         foreach ($element as $fieldsets) {
             $markup .= $this->render($fieldsets, $index++);
         }
         $markup .= '</table>' . $templateMarkup;
     } else {
         if ($element instanceof Game) {
             $markup .= '<tr class="game">' . '<td>Game&nbsp;' . $index . '</td>' . '<td>' . $this->renderField($element->get('goalsTeamOne')) . '</td>' . '<td>:</td>' . '<td>' . $this->renderField($element->get('goalsTeamTwo'), 1) . '</td>' . '</tr>';
             return $markup;
         }
     }
     return sprintf('<div class="row"><div class="span5">%s</div></div>', $markup);
 }
开发者ID:0ida,项目名称:fussi,代码行数:55,代码来源:FormGame.php

示例8: render

 /**
  * Render a collection by iterating through all fieldsets and elements
  *
  * @param  ElementInterface $element
  * @param  string           $templatePartial Required Template Path for manual rendering of template elements
  *
  * @return string
  *
  * @throws InvalidArgumentException
  */
 public function render(ElementInterface $element, $templatePartial)
 {
     if (!$templatePartial) {
         throw new InvalidArgumentException('$templatePartial cannot be null');
     }
     $markup = '';
     $templateMarkup = '';
     $partialHelper = $this->getPartialHelper();
     if ($element instanceof Collection && $element->shouldCreateTemplate()) {
         $templateMarkup = $this->renderTemplate($element, $templatePartial);
     }
     if ($element instanceof Collection) {
         foreach ($element->getIterator() as $collectionFieldset) {
             $markup .= $partialHelper($templatePartial, ['collection' => $collectionFieldset]);
         }
     } else {
         $markup .= $partialHelper($templatePartial, ['collection' => $element]);
     }
     return $templateMarkup . $markup;
 }
开发者ID:manuakasam,项目名称:templated-form-collection,代码行数:30,代码来源:TemplatedFormCollection.php

示例9: 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

示例10: render

 /**
  * Render a collection by iterating through all fieldsets and elements
  *
  * @param  ElementInterface $element
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $markup = '';
     $templateMarkup = '';
     $fieldsetHelper = $this->getFieldsetHelper();
     if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
         $templateMarkup = $this->renderTemplate($element);
     }
     foreach ($element->getIterator() as $elementOrFieldset) {
         if ($elementOrFieldset instanceof FieldsetInterface) {
             $markup .= $fieldsetHelper($elementOrFieldset, $this->shouldWrap());
         } elseif ($elementOrFieldset instanceof ElementInterface) {
             $markup .= Form::row($elementOrFieldset);
         }
     }
     // Every collection is wrapped by a fieldset if needed
     if ($this->shouldWrap) {
         $attributes = $element->getAttributes();
         unset($attributes['name']);
         $attributesString = count($attributes) ? ' ' . $this->createAttributesString($attributes) : '';
         $label = $element->getLabel();
         $legend = '';
         if (!empty($label)) {
             if (null !== ($translator = $this->getTranslator())) {
                 $label = $translator->translate($label, $this->getTranslatorTextDomain());
             }
             if (!$element instanceof LabelAwareInterface || !$element->getLabelOption('disable_html_escape')) {
                 $escapeHtmlHelper = $this->getEscapeHtmlHelper();
                 $label = $escapeHtmlHelper($label);
             }
             $legend = sprintf($this->labelWrapper, $label);
         }
         $markup = sprintf($this->wrapper, $markup, $legend, $templateMarkup, $attributesString);
     } else {
         $markup .= $templateMarkup;
     }
     return $markup;
 }
开发者ID:spotonlive,项目名称:sl-laravel-zf2-form,代码行数:44,代码来源:FormCollection.php

示例11: render

 /**
  * @param ElementInterface $oElement
  * @return string
  */
 public function render(ElementInterface $oElement)
 {
     $html = '';
     if ($oElement instanceof Collection) {
         $c = 0;
         foreach ($oElement as $key => $oElementOrFieldSet) {
             $oFieldSetHelper = $this->getFieldsetHelper();
             if ($oElementOrFieldSet instanceof AbstractLineFieldSet) {
                 $format = str_replace('__index__', $key, $this->rowWrap);
                 $format = str_replace('__label__', $oElementOrFieldSet->get('label')->getValue(), $format);
                 $format = str_replace('__text__', $oElementOrFieldSet->get('text')->getValue(), $format);
                 $html .= sprintf($format, $this->getLineType(), $oFieldSetHelper($oElementOrFieldSet, false), ucfirst($this->getLineType()));
             }
             $c++;
         }
         $html = sprintf($this->collectionWrap, $this->getLineType(), $html);
         if ($oElement instanceof Collection && $oElement->shouldCreateTemplate()) {
             $this->setShouldWrap(false);
             $html .= $this->renderTemplate($oElement);
         }
     } else {
         $html = parent::render($oElement);
     }
     return $html;
 }
开发者ID:uthando-cms,项目名称:uthando-contact,代码行数:29,代码来源:AbstractLineFormCollection.php

示例12: render

 /**
  * @param ElementInterface $element
  * @param bool $useViewPartial
  * @return string
  */
 public function render(ElementInterface $element, $useViewPartial = false)
 {
     /* @var $renderer \Zend\View\Renderer\PhpRenderer */
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         // Bail early if renderer is not pluggable
         return '';
     }
     /* @var $elementHelper \Zend\Form\View\Helper\FormRow */
     $markup = '';
     $templateMarkup = '';
     $escapeHtmlHelper = $this->getEscapeHtmlHelper();
     $elementHelper = $this->getElementHelper();
     $fieldsetHelper = $this->getFieldsetHelper();
     $isCollectionElement = $element instanceof CollectionElement;
     /* @var $element ElementInterface|CollectionElement */
     if ($isCollectionElement && $element->shouldCreateTemplate()) {
         $this->isWithinCollection = true;
         $templateMarkup = $this->renderTemplate($element);
         $this->isWithinCollection = false;
     }
     $elementId = $element->getAttribute('id');
     if (!$elementId) {
         $elementId = preg_replace(array('~[^A-Za-z0-9_-]~', '~--+~', '~^-|-$~'), array('-', '-', ''), $element->getName());
         $element->setAttribute('id', $elementId);
     }
     /*
      * We had the problem, that collection templates were not rendered using the viewPartial due to the call
      * to this function from the parent class, which does not provide the $useViewPartial variable.
      * Currently this is fixed by always using the view partial if $this->isWithinCollection is true.
      *
      * We should consider using a new property $this->useViewPartial, for cover the case, where the
      * template should NOT be rendered using the view partial.
      *
      */
     if ($element instanceof ViewPartialProviderInterface && ($this->isWithinCollection || $useViewPartial)) {
         /* @var $partial \Zend\View\Helper\Partial */
         $partial = $renderer->plugin('partial');
         return $partial($element->getViewPartial(), array('element' => $element));
     }
     foreach ($element->getIterator() as $elementOrFieldset) {
         /* @var $elementOrFieldset ElementInterface|ViewPartialProviderInterface|ViewHelperProviderInterface */
         if ($elementOrFieldset instanceof ViewPartialProviderInterface) {
             $elementOrFieldsetId = $elementOrFieldset->getAttribute('id');
             if (!$elementOrFieldsetId) {
                 $elementOrFieldsetId = preg_replace(array('~[^A-Za-z0-9_-]~', '~--+~', '~^-|-$~'), array('-', '-', ''), $elementOrFieldset->getName());
                 $elementOrFieldset->setAttribute('id', $elementOrFieldsetId);
             }
             /* @var $partial \Zend\View\Helper\Partial */
             $partial = $renderer->plugin('partial');
             $markup .= $partial($elementOrFieldset->getViewPartial(), array('element' => $elementOrFieldset));
         } else {
             if ($elementOrFieldset instanceof FieldsetInterface) {
                 if ($isCollectionElement) {
                     $this->isWithinCollection = true;
                 }
                 if ($elementOrFieldset instanceof ViewHelperProviderInterface) {
                     $helper = $elementOrFieldset->getViewHelper();
                     if (is_string($helper)) {
                         $helper = $renderer->plugin($helper);
                     }
                     $markup .= $helper($element);
                 } else {
                     $markup .= $fieldsetHelper($elementOrFieldset);
                 }
                 $this->isWithinCollection = false;
             } elseif (false !== $elementOrFieldset->getOption('use_formrow_helper')) {
                 $markup .= $elementHelper($elementOrFieldset, null, null, $this->layout);
             } else {
                 /* @var $formElement \Zend\Form\View\Helper\FormElement */
                 $formElement = $renderer->plugin('formelement');
                 $formElement->render($elementOrFieldset);
             }
         }
     }
     // If $templateMarkup is not empty, use it for simplify adding new element in JavaScript
     if (!empty($templateMarkup)) {
         $markup .= $templateMarkup;
     }
     // Every collection is wrapped by a fieldset if needed
     if ($this->shouldWrap) {
         if ($this->isWithinCollection) {
             $attrStr = $this->createAttributesString($element->getAttributes());
             $markup = sprintf('<fieldset %s><a class="remove-item yk-form-remove"><i class="yk-icon yk-icon-minus"></i></a>%s</fieldset>', $attrStr, $markup);
         } else {
             $label = $element->getLabel();
             if (empty($label) && $element->getOption('renderFieldset')) {
                 $attrStr = $this->createAttributesString($element->getAttributes());
                 $markup = sprintf('<fieldset %s><div class="fieldset-content">%s</div></fieldset>', $attrStr, $markup);
             } else {
                 if (!empty($label)) {
                     if (null !== ($translator = $this->getTranslator())) {
                         $label = $translator->translate($label, $this->getTranslatorTextDomain());
                     }
                     $label = $escapeHtmlHelper($label);
//.........这里部分代码省略.........
开发者ID:vfulco,项目名称:YAWIK,代码行数:101,代码来源:FormCollection.php

示例13: 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();
     $elementHelper = $this->getElementHelper();
     $fieldsetHelper = $this->getFieldsetHelper();
     $isCollectionElement = $element instanceof CollectionElement;
     if ($isCollectionElement && $element->shouldCreateTemplate()) {
         $this->isWithinCollection = true;
         $templateMarkup = $this->renderTemplate($element);
         $this->isWithinCollection = false;
     }
     foreach ($element->getIterator() as $elementOrFieldset) {
         if ($elementOrFieldset instanceof ViewPartialProviderInterface) {
             $markup .= $this->getView()->partial($elementOrFieldset->getViewPartial(), array('element' => $elementOrFieldset));
         } else {
             if ($elementOrFieldset instanceof FieldsetInterface) {
                 if ($isCollectionElement) {
                     $this->isWithinCollection = true;
                 }
                 if ($elementOrFieldset instanceof ViewHelperProviderInterface) {
                     $helper = $elementOrFieldset->getViewHelper();
                     if (is_string($helper)) {
                         $helper = $renderer->plugin($helper);
                     }
                     $markup .= $helper($element);
                 } else {
                     $markup .= $fieldsetHelper($elementOrFieldset);
                 }
                 $this->isWithinCollection = false;
             } elseif ($elementOrFieldset instanceof ElementInterface) {
                 $markup .= $elementHelper($elementOrFieldset, null, null, $this->layout);
             }
         }
     }
     // If $templateMarkup is not empty, use it for simplify adding new element in JavaScript
     if (!empty($templateMarkup)) {
         $markup .= $templateMarkup;
     }
     // Every collection is wrapped by a fieldset if needed
     if ($this->shouldWrap) {
         $elementId = $element->getAttribute('id');
         if (!$elementId) {
             $elementId = preg_replace(array('~[^A-Za-z0-9_-]~', '~--+~', '~^-|-$~'), array('-', '-', ''), $element->getName());
             $element->setAttribute('id', $elementId);
         }
         if ($this->isWithinCollection) {
             $attrStr = $this->createAttributesString($element->getAttributes());
             $markup = sprintf('<fieldset %s><a class="remove-item cam-form-remove"><i class="yk-icon yk-icon-minus"></i></a>%s</fieldset>', $attrStr, $markup);
         } else {
             $label = $element->getLabel();
             if (empty($label) && $element->getOption('renderFieldset')) {
                 $attrStr = $this->createAttributesString($element->getAttributes());
                 $markup = sprintf('<fieldset %s><div class="fieldset-content">%s</div></fieldset>', $attrStr, $markup);
             } else {
                 if (!empty($label)) {
                     if (null !== ($translator = $this->getTranslator())) {
                         $label = $translator->translate($label, $this->getTranslatorTextDomain());
                     }
                     $label = $escapeHtmlHelper($label);
                     if ($isCollectionElement) {
                         $extraLegend = '<a href="#" class="add-item cam-form-add"><i class="yk-icon yk-icon-plus"></i></a>';
                         $class = $element->getAttribute('class');
                         $class .= " form-collection";
                         $element->setAttribute('class', $class);
                         $divWrapperOpen = $divWrapperClose = '';
                     } else {
                         $extraLegend = $class = '';
                         $divWrapperOpen = '<div class="fieldset-content">';
                         $divWrapperClose = '</div>';
                     }
                     $attrStr = $this->createAttributesString($element->getAttributes());
                     $markup = sprintf('<fieldset %s><legend>%s%s</legend>%s%s%s</fieldset>', $attrStr, $label, $extraLegend, $divWrapperOpen, $markup, $divWrapperClose);
                 }
             }
         }
     }
     return $markup;
 }
开发者ID:bitrecruiter,项目名称:CrossApplicantManager,代码行数:91,代码来源:FormCollection.php

示例14: getControl

 /**
  * @param ElementInterface $element
  * @return string
  */
 protected function getControl(ElementInterface $element)
 {
     $control = '';
     if ($element instanceof Collection && $element->allowAdd() && $element->shouldCreateTemplate()) {
         $control = ' <button type="button" class="btn btn-add-fieldset" ' . 'onclick="return CmsCommon.Form.Collection.addFieldset(this, \'prepend\');">' . '+</button>';
     } elseif ($element instanceof FieldsetInterface && !$element instanceof Collection && $element->getOption('allow_remove')) {
         $control = ' <button type="button" class="btn btn-remove-fieldset" ' . 'onclick="return CmsCommon.Form.Collection.removeFieldset(this);">' . '-</button>';
     }
     return $control;
 }
开发者ID:coolms,项目名称:common,代码行数:14,代码来源:FormCollection.php


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