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


PHP ElementInterface::getOption方法代码示例

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


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

示例1: render

 /**
  * {@inheritDoc}
  */
 public function render(ElementInterface $element, $options = array())
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new \DomainException(sprintf('%s requires that the element has a "captcha" attribute' . ' implementing Zend\\Captcha\\AdapterInterface; none found', __METHOD__));
     }
     $helper = $captcha->getHelperName();
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         throw new \DomainException(sprintf('%s requires that the renderer implements plugin();' . ' it does not', __METHOD__));
     }
     $helper = $renderer->plugin($helper);
     // Custom CAPTCHA view
     $separator = null;
     if (isset($options['separator'])) {
         $separator = $options['separator'];
     } elseif ($element->getOption('separator')) {
         $separator = $element->getOption('separator');
     }
     if (null !== $separator) {
         $helper->setSeparator($separator);
     }
     $position = null;
     if (isset($options['captcha_position'])) {
         $position = $options['captcha_position'];
     } elseif ($element->getOption('captcha_position')) {
         $position = $element->getOption('captcha_position');
     }
     if (null !== $position) {
         $helper->setCaptchaPosition($position);
     }
     return $helper($element);
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:36,代码来源:FormCaptcha.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: prepareElementBeforeRendering

 /**
  * Prepares the element prior to rendering
  * @param \Zend\Form\ElementInterface $element
  * @param string $formType
  * @param array $displayOptions
  * @return void
  */
 protected function prepareElementBeforeRendering(ElementInterface $element, $formType, array $displayOptions)
 {
     $class = $element->getAttribute('class');
     $class = $this->genUtil->addWords('btn', $class);
     if (array_key_exists('class', $displayOptions)) {
         $class = $this->genUtil->addWords($displayOptions['class'], $class);
     }
     if ($element->getOption('primary') && $element->getOption('primary') == true) {
         $class = $this->genUtil->addWords('btn-primary', $class);
     }
     $class = $this->genUtil->escapeWords($class, $this->getEscapeHtmlAttrHelper());
     $element->setAttribute('class', $class);
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:20,代码来源:FormSubmitTwb.php

示例4: render

 /**
  * Render
  *
  * @param  \Zend\Form\ElementInterface $element
  * @param  string                      $blockWrapper
  * @param  string                      $inlineWrapper
  * @return string
  */
 public function render(ElementInterface $element, $blockWrapper = null, $inlineWrapper = null)
 {
     $blockWrapper = $blockWrapper ?: $this->blockWrapper;
     $inlineWrapper = $inlineWrapper ?: $this->inlineWrapper;
     $html = '';
     if ($inline = $element->getOption('help-inline')) {
         $html .= sprintf($inlineWrapper, $inline);
     }
     if ($block = $element->getOption('help-block')) {
         $html .= sprintf($blockWrapper, $block);
     }
     return $html;
 }
开发者ID:suitedJK,项目名称:ZfcTwitterBootstrap,代码行数:21,代码来源:FormDescription.php

示例5: render

 /**
  * Render element hint from the provided $element
  * @param  ElementInterface $element
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $type = $element->getAttribute('type');
     if (!in_array($type, $this->supportedTypes)) {
         return '';
     }
     $escapeHelper = $this->getEscapeHtmlHelper();
     $html = '';
     //Hint
     if ($element->getOption('hint')) {
         $html = '<span class="help-inline">' . $escapeHelper($element->getOption('hint')) . '</span>';
     }
     return $html;
 }
开发者ID:dannytrue,项目名称:dlutwbootstrap,代码行数:19,代码来源:FormHintTwb.php

示例6: render

 /**
  * Render a description from the provided $element
  * @param  ElementInterface $element
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $type = $element->getAttribute('type');
     if (!in_array($type, $this->supportedTypes)) {
         return '';
     }
     $escapeHelper = $this->getEscapeHtmlHelper();
     $html = '';
     //Description
     if ($element->getOption('description')) {
         $html = '<p class="help-block">' . $escapeHelper($element->getOption('description')) . '</p>';
     }
     return $html;
 }
开发者ID:dannytrue,项目名称:dlutwbootstrap,代码行数:19,代码来源:FormDescriptionTwb.php

示例7: __invoke

 /**
  * @param ElementInterface $element
  * @param boolean          $block
  *
  * @return string
  */
 public function __invoke(ElementInterface $element, $block = false)
 {
     $this->setElement(new HtmlElement('span'));
     $message = null;
     if (($message = $element->getOption('description-inline')) || ($message = $element->getOption('description'))) {
         $this->addClass('help-inline');
     } elseif ($message = $element->getOption('description-block')) {
         $this->addClass('help-block');
     }
     if (null === $message) {
         return '';
     }
     $this->setDescription($message);
     return $this->render();
 }
开发者ID:spoonx,项目名称:sxbootstrap,代码行数:21,代码来源:Description.php

示例8: render

 /**
  * @return string
  */
 public function render(\Zend\Form\ElementInterface $oElement)
 {
     $config = $this->getConfig();
     $name = $oElement->getName();
     // Check whether some options have been passed via the form element
     // options
     $options = $oElement->getOption('ckeditor');
     if (!empty($options) && !is_array($options)) {
         throw \Exception('The options should either be an array or a traversable object');
     } elseif (empty($options)) {
         $options = array();
     }
     $ckfinderLoaded = $this->getModuleManager()->getModule('CKFinderModule') !== null;
     // Because zf merges arrays instead of overwriting them in the config,
     // we allow a callback and use the return as the toolbar array
     if (array_key_exists('toolbar', $config['ckeditor_options']) && is_callable($config['ckeditor_options']['toolbar'])) {
         $toolbar = $config['ckeditor_options']['toolbar']();
         if (is_array($toolbar)) {
             $config['ckeditor_options']['toolbar'] = $toolbar;
         }
     }
     // Merge the defaut edito options with the form element options
     // and turn them into json
     $jsonOptions = JsonFormatter::encode(array_merge($config['ckeditor_options'], $ckfinderLoaded ? $config['ckeditor_ckfinder_options'] : array(), $options), true);
     $loadFunctionName = $this->getTmpLoadFunctionName();
     $src = $config['src'];
     return parent::render($oElement) . '<script type="text/javascript" language="javascript">' . "\n" . 'if(typeof window.ckEditorLoading == "undefined"){' . "\n" . 'window.ckEditorLoading = false;' . "\n" . 'window.ckEditorCallbacks = [];' . "\n" . '}' . "\n" . '(function() {' . "\n" . 'function ' . $loadFunctionName . '(){' . "\n" . 'CKEDITOR.replace("' . $name . '", ' . $jsonOptions . ');' . "\n" . '}' . "\n" . 'if(typeof CKEDITOR == "undefined"){' . "\n" . 'window.ckEditorCallbacks.push(' . $loadFunctionName . ');' . "\n" . 'if(!window.ckEditorLoading) {' . "\n" . 'window.ckEditorLoading = true;' . "\n" . 'var ckScript = document.createElement("script");' . "\n" . 'ckScript.type = "text/javascript";' . "\n" . 'ckScript.async = false;' . "\n" . 'ckScript.src = "' . $src . '";' . "\n" . 'var target = document.getElementsByTagName("script")[0];' . "\n" . 'target.parentNode.insertBefore(ckScript, target);' . "\n" . 'var ckEditorInterval = setInterval(function(){' . "\n" . 'if(typeof CKEDITOR != "undefined"){' . "\n" . 'clearInterval(ckEditorInterval);' . "\n" . 'for(var i in window.ckEditorCallbacks) window.ckEditorCallbacks[i]();' . "\n" . '}' . "\n" . '}, 100);' . "\n" . '}' . "\n" . '}' . "\n" . '})();' . "\n" . '</script>' . "\n";
 }
开发者ID:egoncommerce,项目名称:CKEditorModule,代码行数:31,代码来源:FormCKEditor.php

示例9: render

 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if (!$content && !($content = $element->getOption('description'))) {
         return '';
     }
     return parent::render($content, $attribs, $element, $form);
 }
开发者ID:coolms,项目名称:common,代码行数:10,代码来源:ElementDescription.php

示例10: render

 /**
  * Render a form <select> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof SelectElement) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Select', __METHOD__));
     }
     $name = $element->getName();
     if (empty($name) && $name !== 0) {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $options = $element->getValueOptions();
     if (($emptyOption = $element->getEmptyOption()) !== null) {
         $options = array('' => $emptyOption) + $options;
     }
     $attributes = $element->getAttributes();
     $value = $this->validateMultiValue($element->getValue(), $attributes);
     $attributes['name'] = $name;
     if (array_key_exists('multiple', $attributes) && $attributes['multiple']) {
         $attributes['name'] .= '[]';
     }
     $this->validTagAttributes = $this->validSelectAttributes;
     $size = $element->getOption('size');
     if (empty($size)) {
         return sprintf('<select %s>%s</select>', $this->createAttributesString($attributes), $this->renderOptions($options, $value));
     }
     return sprintf('<div class="col-lg-%s col-md-%s col-sm-%s col-xs-%s">
             <select %s>%s</select>
         </div>', $size, $size, $size, $size, $this->createAttributesString($attributes), $this->renderOptions($options, $value));
 }
开发者ID:skpd,项目名称:bootstrap,代码行数:36,代码来源:FormSelect.php

示例11: render

 /**
  * Render editor
  *
  * @param  ElementInterface $element
  *
  * @throws \Zend\Form\Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $renderer = $this->getView();
     if (!method_exists($renderer, 'plugin')) {
         // Bail early if renderer is not pluggable
         return '';
     }
     $name = $element->getName();
     if (empty($name) && $name !== 0) {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name;' . ' none discovered', __METHOD__));
     }
     $options = $element->getOptions();
     /*
     $attributes = $element->getAttributes();
     $attributes['value'] = $element->getValue();
     $options['attributes'] = $attributes;
     */
     $editorType = $element->getOption('editor') ?: 'textarea';
     $editor = EditorFactory::load($editorType, $options);
     $html = '';
     if ($editor) {
         $html = $editor->setView($renderer)->render($element);
     }
     if (!$html) {
         $html = $renderer->formTextarea($element);
     }
     return $html;
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:36,代码来源:FormEditor.php

示例12: render

 public function render(ElementInterface $element)
 {
     if ($element->getOption('use-switch')) {
         $element->setAttribute('data-switch', '1');
     }
     return parent::render($element);
 }
开发者ID:xelax90,项目名称:xelax-twb-unmask,代码行数:7,代码来源:FormCheckbox.php

示例13: render

 public function render(ElementInterface $element)
 {
     if ($element->getOption('static')) {
         return $this->getView()->formElementStatic($element);
     }
     return parent::render($element);
 }
开发者ID:phower,项目名称:zf2-bootstrap3-module,代码行数:7,代码来源:FormDateTime.php

示例14: render

 /**
  * {@inheritDoc}
  */
 public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
 {
     if ($element && !$element->getOption('input_group')) {
         return $content;
     }
     return parent::render($content, $attribs, $element, $form);
 }
开发者ID:coolms,项目名称:twbs,代码行数:10,代码来源:InputGroup.php

示例15: render

 public function render(ElementInterface $element)
 {
     $element->setAttribute('data-role', 'datepicker');
     if ($element->getOption('default-today')) {
         $element->setAttribute('data-default-today', 'true');
     }
     return parent::render($element);
 }
开发者ID:DavidHavl,项目名称:Ajasta,代码行数:8,代码来源:FormDatePicker.php


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