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


PHP Form\ElementInterface类代码示例

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


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

示例1: render

 public function render(ElementInterface $element = null)
 {
     if ($element->getMessages()) {
         $element->setAttribute('class', 'error ' . $element->getAttribute('class'));
     }
     return parent::render($element);
 }
开发者ID:3makkk,项目名称:Foundation,代码行数:7,代码来源:FormElement.php

示例2: openTag

 /**
  * Returns the control group open tag
  * @param ElementInterface $element
  * @return string
  */
 public function openTag(ElementInterface $element)
 {
     $class = 'controls';
     $id = 'controls-' . $element->getName();
     $html = sprintf('<div class="%s" id="%s">', $class, $id);
     return $html;
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:12,代码来源:FormControlsTwb.php

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

示例4: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @param String $buttonContent
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element, $buttonContent = null)
 {
     //$view = $this->getView();
     //$view->headScript()->appendFile($view->basePath('/Core/js/bootstrap-switch.js'));
     if (null === $buttonContent) {
         $buttonContent = $element->getLabel();
         if (null === $buttonContent) {
             throw new Exception\DomainException(sprintf('%s expects either button content as the second argument, ' . 'or that the element provided has a label value; neither found', __METHOD__));
         }
         if (null !== ($translator = $this->getTranslator())) {
             $buttonContent = $translator->translate($buttonContent, $this->getTranslatorTextDomain());
         }
         $element->setLabel('');
     }
     //$escape         = $this->getEscapeHtmlHelper();
     //$translator     = $this->getTranslator();
     //$name           = $element->getName();
     $value = $element->getValue();
     $checkedBoole = $value == 1 || $value == 'on';
     //$checked        = $checkedBoole?'checked="checked"':'';
     $checkedClass = $checkedBoole ? 'active"' : '';
     $buttonContent = '<div class="btn-group" data-toggle="buttons">' . PHP_EOL . '<span class="btn btn-default ' . $checkedClass . '">' . PHP_EOL . parent::render($element) . $buttonContent . PHP_EOL . '</span>' . PHP_EOL . '</div>' . PHP_EOL;
     //$buttonContent = '<div><div class="processing yk-hidden"><span class="fa-spin yk-icon-spinner yk-icon"></span> ' .
     //    $translator->translate('processing', $this->getTranslatorTextDomain()) . '</div><div class="default">' . $escape($buttonContent) . '</div></div>';
     return $buttonContent;
 }
开发者ID:vfulco,项目名称:YAWIK,代码行数:34,代码来源:ToggleButton.php

示例5: render

 public function render(ElementInterface $element)
 {
     /* just a reminder. the types are:
     			checkbox, color, date, datetime, datetime-local, email, file, hidden
     			image, month, multi_checkbox, number, password, radio, range, reset
     			search, select, submit, tel, text, textarea, time, url, week
     		*/
     $labelHelper = $this->getLabelHelper();
     $escapeHelper = $this->getEscapeHtmlHelper();
     $elementHelper = $this->getElementHelper();
     $elementErrorHelper = $this->getElementErrorHelper();
     $descriptionHelper = $this->getDescriptionHelper();
     $groupWrapper = $groupWrapper ?: $this->groupWrapper;
     $controlWrapper = $controlWrapper ?: $this->controlWrapper;
     $id = $element->getAttribute('id') ?: $element->getAttribute('name');
     $html = "";
     $label = $element->getAttribute('label');
     if ($label) {
         $html .= $labelHelper->openTag(array('for' => $id, 'class' => 'control-label'));
         // todo allow for not escaping the label
         $html .= $escapeHelper($label);
         $html .= $labelHelper->closeTag();
     }
     $html .= sprintf($controlWrapper, $id, $elementHelper->render($element), $descriptionHelper->render($element), $elementErrorHelper->render($element));
     $addtClass = $element->getMessages() ? ' error' : '';
     echo $element->getLabel();
     die;
     $output .= parent::render($element);
     return $output;
 }
开发者ID:rafajaques,项目名称:colloquium,代码行数:30,代码来源:_FormElement.php

示例6: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $name = $element->getName();
     if ($name === null || $name === '') {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $attributes = $element->getAttributes();
     $attributes['type'] = $this->getType($element);
     $attributes['name'] = $name;
     if (array_key_exists('multiple', $attributes) && $attributes['multiple']) {
         $attributes['name'] .= '[]';
     }
     $value = $element->getValue();
     if (is_array($value) && isset($value['name']) && !is_array($value['name'])) {
         $attributes['value'] = $value['name'];
     } elseif (is_string($value)) {
         $attributes['value'] = $value;
     }
     $size = $element->getOption('size');
     if (empty($size)) {
         return sprintf('<input %s%s', $this->createAttributesString($attributes), $this->getInlineClosingBracket());
     }
     return sprintf('<div class="col-lg-%s col-md-%s col-sm-%s col-xs-%s">
             <input %s%s
         </div>', $size, $size, $size, $size, $this->createAttributesString($attributes), $this->getInlineClosingBracket());
 }
开发者ID:skpd,项目名称:bootstrap,代码行数:33,代码来源:FormFile.php

示例7: render

    /**
     * {@inheritDoc}
     */
    public function render(ElementInterface $element)
    {
        if (!$element instanceof LoginFieldElement) {
            return '';
        }
        $fields = $element->getFields();
        if (1 == count($fields)) {
            $element->setAttribute('placeholder', current($fields));
            return parent::render($element);
        }
        $template = $element->getOption('template') ?: '<div class="input-group">%s</div>';
        $pattern = <<<EOT
<input name="%s[0]" %s%s
<span class="input-group-addon">
    <select class="pull-right" name="%s[1]">
        %s
    </select>
</span>
EOT;
        $name = $element->getName();
        list($value, $field) = $element->getValue();
        $attributes = array_replace($element->getAttributes(), array('type' => 'text', 'value' => $value));
        if (!isset($attributes['class'])) {
            $attributes['class'] = 'form-control';
        }
        $attribString = $this->createAttributesString($attributes);
        $patternField = '<option value="%s"%s>%s</option>' . PHP_EOL;
        $fieldString = '';
        foreach ($fields as $key => $label) {
            $class = $field == $key ? ' selected' : '';
            $fieldString .= sprintf($patternField, $key, $class, $label);
        }
        $html = sprintf($template, sprintf($pattern, $name, $attribString, $this->getInlineClosingBracket(), $name, $fieldString));
        return $html;
    }
开发者ID:Andyyang1981,项目名称:pi,代码行数:38,代码来源:FormLoginField.php

示例8: render

 public function render(ElementInterface $element)
 {
     if (in_array($element->getAttribute('type'), array('html'))) {
         return $element->getValue();
     }
     return parent::render($element);
 }
开发者ID:ualisonaguiar,项目名称:shome2,代码行数:7,代码来源:FormRow.php

示例9: render

 /**
  * {@inheritDoc}
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute' . ' of type Zend\\Captcha\\Image; none found', __METHOD__));
     }
     // Generates ID, but NOT word and image
     $captcha->generate();
     // Generates URL to access image, and image won't be generated until the URL is accessed
     $imgSrc = $captcha->getImgUrl() . '?id=' . $captcha->getId();
     $imgAttributes = array('width' => $captcha->getWidth(), 'height' => $captcha->getHeight(), 'src' => $imgSrc, 'onclick' => sprintf('this.src=\'%s&refresh=\'+Math.random()', $imgSrc), 'style' => 'cursor: pointer; vertical-align: middle;', 'alt' => __('CAPTCHA image'), 'title' => __('Click to refresh CAPTCHA'));
     if ($element->hasAttribute('id')) {
         $imgAttributes['id'] = $element->getAttribute('id') . '-image';
     } else {
         $imgAttributes['id'] = $captcha->getId() . '-image';
     }
     $closingBracket = $this->getInlineClosingBracket();
     $img = sprintf('<img %s%s', $this->createAttributesString($imgAttributes), $closingBracket);
     $position = $this->getCaptchaPosition();
     $separator = $this->getSeparator();
     $captchaInput = $this->renderCaptchaInputs($element);
     $pattern = '%s%s%s';
     if ($position == static::CAPTCHA_PREPEND) {
         return sprintf($pattern, $captchaInput, $separator, $img);
     }
     return sprintf($pattern, $img, $separator, $captchaInput);
 }
开发者ID:Andyyang1981,项目名称:pi,代码行数:30,代码来源:Image.php

示例10: render

 /**
  * Render a form radio-group element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof RadioGroup) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zork\\Form\\Element\\RadioGroup', __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 (empty($options)) {
         if (($translator = $this->getTranslator()) !== null) {
             return '<i>' . $translator->translate('default.empty', 'default') . '</i>';
         } else {
             return '';
         }
     }
     if (($emptyOption = $element->getEmptyOption()) !== null) {
         $options = array('' => $emptyOption) + $options;
     }
     $attributes = $element->getAttributes();
     $value = $element->getValue();
     $additionalAttribures = array('type' => 'radio', 'name' => $name, 'required' => empty($attributes['required']) ? null : 'required');
     $this->validTagAttributes = $this->validRadioGroupAttributes;
     return sprintf('<div %s>%s</div>', $this->createAttributesString($attributes), $this->renderRadios($options, $value, $additionalAttribures, $element->getOption('option_attribute_filters')));
 }
开发者ID:gridguyz,项目名称:zork,代码行数:34,代码来源:FormRadioGroup.php

示例11: render

 /**
  * Renders a form element label from an element
  * @param \Zend\Form\ElementInterface $element
  * @param array|null $displayOptions
  * @return string
  * @throws \Zend\Form\Exception\DomainException
  */
 public function render(ElementInterface $element, array $displayOptions = array())
 {
     $labelContent = $element->getLabel();
     if (empty($labelContent)) {
         throw new DomainException(sprintf('%s: No label set in the element.', __METHOD__));
     }
     //Translate
     if (null !== ($translator = $this->getTranslator())) {
         $labelContent = $translator->translate($labelContent, $this->getTranslatorTextDomain());
     }
     //Escape
     $escaperHtml = $this->getEscapeHtmlHelper();
     $labelContent = $escaperHtml($labelContent);
     //Label attributes
     $labelAttributes = $element->getLabelAttributes();
     if (empty($labelAttributes)) {
         $labelAttributes = array();
     }
     $labelAttributes = $this->genUtil->addWordsToArrayItem('control-label', $labelAttributes, 'class');
     if (array_key_exists('required', $displayOptions) && $displayOptions['required']) {
         $labelAttributes = $this->genUtil->addWordsToArrayItem('required', $labelAttributes, 'class');
     }
     $element->setLabelAttributes($labelAttributes);
     $formLabelHelper = $this->formLabelHelper;
     return $formLabelHelper($element, $labelContent);
 }
开发者ID:dannytrue,项目名称:dlutwbootstrap,代码行数:33,代码来源:FormLabelTwb.php

示例12: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $name = $element->getName();
     if ($name === null || $name === '') {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $attributes = $element->getAttributes();
     $attributes['name'] = $name;
     $attributes['type'] = $this->getType($element);
     $attributes['value'] = $element->getValue();
     //ADD OPTIONS
     //	this should really be in Stjonvisi\Form\Element\Img
     //	but it gets overwritten at some point, so the simplest
     //	thing was to add it here.
     //	TODO place this i a more generic place
     $element->setOption('max', $this->getMaxSize())->setOption('url', '/skrar/mynd')->setOption('accept', 'image/*')->setOption('mime', '/image\\/jpg|jpeg|png|gif/');
     //OPTIONS
     //	options are used to set attributes and values
     //	to the custom element. We therefore need to remove
     //	label, label_attributes and label_options before we
     //	can convert them into an attribute string.
     $options = $element->getOptions();
     unset($options['label']);
     unset($options['label_attributes']);
     unset($options['label_options']);
     $strings = array_map(function ($key, $value) {
         return sprintf('%s="%s"', $key, $value);
     }, array_keys($options), $options);
     return sprintf('<stjornvisi-img %s><input %s%s</stjornvisi-img>', implode(' ', $strings), $this->createAttributesString($attributes), $this->getInlineClosingBracket());
 }
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:37,代码来源:ImgElement.php

示例13: render

 /**
  * Render a form checkbox-group element from the provided $element
  *
  * @param   \Zend\Form\ElementInterface $element
  * @throws  \Zend\Form\Exception\InvalidArgumentException
  * @throws  \Zend\Form\Exception\DomainException
  * @return  string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof TagBanners) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Grid\\Banner\\Form\\Element\\TagBanners', __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__));
     }
     $appService = $this->getAppServiceHelper();
     $tagModel = $appService('Grid\\Tag\\Model\\Tag\\Model');
     $attributes = $element->getAttributes();
     $value = (array) $element->getValue();
     $groups = array();
     foreach ($value as $tagId => $banners) {
         $tag = $tagModel->find($tagId);
         if ($tag && $tag->locale) {
             $locale = 'locale.sub.' . $tag->locale;
             if ($this->isTranslatorEnabled() && $this->hasTranslator()) {
                 $locale = $this->getTranslator()->translate($locale, 'locale');
             }
         }
         $label = $tag ? $tag->name . (isset($locale) ? ' (' . $locale . ')' : '') : '#' . $tagId;
         $groups[] = array('header' => $label, 'markup' => $this->renderBanners($name . '[' . $tagId . ']', $banners), 'attributes' => array('data-tagid' => $tagId));
     }
     unset($attributes['name']);
     return $this->renderBannerGroups($name . '[__tagid__]', $attributes, $groups);
 }
开发者ID:gridguyz,项目名称:banner,代码行数:36,代码来源:FormBannerTags.php

示例14: __invoke

 public function __invoke(ElementInterface $element = null)
 {
     if ($element && !$element->hasAttribute('class')) {
         $this->addClasses($element, ['btn', 'btn-default']);
     }
     return parent::__invoke($element);
 }
开发者ID:phower,项目名称:zf2-bootstrap3-module,代码行数:7,代码来源:FormSubmit.php

示例15: render

 /**
  * Override
  * 
  * Render the captcha
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     //we could also set the separator here to break between the inputs and the image.
     //$this->setSeparator('')
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof CaptchaAdapter) {
         throw new DomainException(sprintf('%s requires that the element has a "captcha" attribute of type Recruitment\\Model\\CaptchaImage;
     none found', __METHOD__));
     }
     $captcha->generate();
     $imgAttributes = array('width' => $captcha->getWidth(), 'height' => $captcha->getHeight(), 'alt' => $captcha->getImgAlt(), 'src' => $captcha->getImgUrl() . $captcha->getId() . $captcha->getSuffix(), 'class' => 'thumbnail center-block');
     if ($element->hasAttribute('id')) {
         $imgAttributes['id'] = $element->getAttribute('id') . '-image';
     }
     $closingBracket = $this->getInlineClosingBracket();
     $img = sprintf('<img  %s%s ', $this->createAttributesString($imgAttributes), $closingBracket);
     $position = $this->getCaptchaPosition();
     $separator = $this->getSeparator();
     $captchaInput = $this->renderCaptchaInputs($element);
     $pattern = '%s' . '<div class="input-group">' . '%s%s' . '<span class="input-group-btn">' . '<button id="' . $element->getAttribute('id') . '-refresh' . '" class="btn btn-default" type="button">' . '<i class="ion-loop"></i>' . '</button>' . '</span>' . '</div>';
     if ($position == self::CAPTCHA_PREPEND) {
         return sprintf($pattern, $captchaInput, $separator, $img);
     }
     return sprintf($pattern, $img, $separator, $captchaInput);
 }
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:34,代码来源:CaptchaImage.php


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