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


PHP ElementInterface::allowRemove方法代码示例

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


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

示例1: __invoke

 /**
  * Render a collection by iterating through all fieldsets and elements.
  *
  * If no arguments are provided, returns object instance.
  *
  * @param  ElementInterface $element    Form collection or fieldset to populate in the view
  * @param  bool $wrap
  * @param  string|bool $partial         Name of partial view script
  * @return string|self
  */
 public function __invoke(ElementInterface $element = null, $wrap = true, $partial = true)
 {
     if (0 === func_num_args()) {
         return $this;
     }
     if ($element instanceof Collection && ($element->allowRemove() || $element->allowAdd())) {
         $headScript = $this->getView()->plugin('headScript');
         $basePath = $this->getView()->plugin('basePath');
         $headScript()->appendFile($basePath('assets/cms-common/js/form/collection.js'));
     }
     $this->setShouldWrap($wrap);
     $this->setPartial($partial);
     return $this->render($element);
 }
开发者ID:coolms,项目名称:common,代码行数:24,代码来源:FormCollection.php

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

示例3: needsButtons

 /**
  * Determines whether this element needs the add/remove buttons at all.
  * @param ElementInterface $element
  * @return boolean
  */
 protected function needsButtons(ElementInterface $element)
 {
     if (!$element instanceof Collection) {
         return false;
     }
     return $element->allowAdd() || $element->allowRemove();
 }
开发者ID:Primetron,项目名称:Edusoft,代码行数:12,代码来源:FieldCollection.php


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