當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。