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


PHP ElementInterface::getAttribute方法代码示例

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


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

示例1: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param ElementInterface $element Zend Form Element
  *
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof CheckboxElement) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Checkbox', __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__));
     }
     $attributes = $element->getAttributes();
     $attributes['name'] = $name;
     $attributes['type'] = $this->getInputType();
     $attributes['value'] = $element->getCheckedValue();
     $closingBracket = $this->getInlineClosingBracket();
     if ($element->isChecked()) {
         $attributes['checked'] = 'checked';
     }
     if ($element->getAttribute('class') != 'input-checkbox') {
         $rendered = sprintf('<input %s%s', $this->createAttributesString($attributes), $closingBracket);
     } else {
         if ($element->getAttribute('id') == '') {
             $element->setAttribute('id', 'checkbox-' . uniqid());
         }
         unset($attributes['class']);
         $rendered = sprintf('<span class="input-checkbox"><input %s%s<label for="%s"></label></span>', $this->createAttributesString($attributes), $closingBracket, $element->getAttribute('id'));
     }
     return $rendered;
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:37,代码来源:FormCheckbox.php

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

示例3: closeTag

 /**
  * Return a closing label tag
  *
  * @return string
  */
 public function closeTag()
 {
     $result = '</label>';
     if ($this->element->hasAttribute('required') && $this->element->getAttribute('required')) {
         $result = sprintf('<span class="required-mark">*</span> %s', $result);
     }
     return $result;
 }
开发者ID:kokspflanze,项目名称:PServerCore,代码行数:13,代码来源:FormLabel.php

示例4: render

 /**
  * @param ElementInterface $element
  *
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $captcha = $element->getCaptcha();
     if ($captcha === null || !$captcha instanceof AdapterInterface) {
         throw new Exception\DomainException(sprintf('%s requires that the element has a "captcha" attribute implementing Zend\\Captcha\\AdapterInterface', __METHOD__));
     }
     $name = $element->getName();
     $id = $element->getAttribute('id') ? $element->getAttribute('id') : $name;
     $captchaPattern = '<div %s></div>';
     $captchaAttributes = $this->createAttributesString(array('class' => 'g-recaptcha ' . $element->getAttribute('class'), 'data-sitekey' => $captcha->getSiteKey(), 'data-theme' => $captcha->getTheme(), 'data-type' => $captcha->getType(), 'data-callback' => $captcha->getCallback()));
     $captchaElement = sprintf($captchaPattern, $captchaAttributes);
     $input = $this->renderHiddenInput($id, $name);
     $js = $this->renderJsCallback($captcha->getCallback(), $id);
     return $captchaElement . $input . $js;
 }
开发者ID:srggroup,项目名称:zf2nocaptcha,代码行数:20,代码来源:NoCaptchaHelper.php

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

示例6: render

 public function render(ElementInterface $element)
 {
     $element->setAttribute('class', $element->getAttribute('class') . " btn");
     $input = parent::render($element);
     $options = $element->getOptions();
     if (!empty($options['as-group'])) {
         $col_left_width = 'sm-6';
         $col_right_width = 'sm-6';
         $button_column = 'left';
         if (!empty($options['col-left-width'])) {
             $col_left_width = $options['col-left-width'];
         }
         if (!empty($options['col-right-width'])) {
             $col_right_width = $options['col-right-width'];
         }
         if (!empty($options['button-column'])) {
             $button_column = $options['button-column'];
         }
         $colFormat = '<div class="col-%s">%s</div><div class="col-%s">%s</div>';
         $buttonFormat = '<div class="btn-group btn-group-justified"><div class="btn-group">%s</div></div>';
         $inputContainer = sprintf($buttonFormat, $input);
         $leftColumn = $inputContainer;
         $rightColumn = '';
         if ($button_column != 'left') {
             $leftColumn = '';
             $rightColumn = $inputContainer;
         }
         $input = sprintf($colFormat, $col_left_width, $leftColumn, $col_right_width, $rightColumn);
     }
     return $input;
 }
开发者ID:xelax90,项目名称:xelax-twb-unmask,代码行数:31,代码来源:FormSubmit.php

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

示例8: init

 public function init(ElementInterface $element)
 {
     $this->formElement = $element;
     if ($element->hasAttribute('template')) {
         $this->template = $element->getAttribute('template');
     }
 }
开发者ID:vfulco,项目名称:YAWIK,代码行数:7,代码来源:TemplateProvider.php

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

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

示例11: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $src = $element->getAttribute('src');
     if (empty($src)) {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned src; none discovered', __METHOD__));
     }
     return parent::render($element);
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:15,代码来源:FormImage.php

示例12: render

 public function render(ElementInterface $element)
 {
     if ($element->hasAttribute('data-placeholder')) {
         $placeholder = $element->getAttribute('data-placeholder');
         $placeholder = $this->getTranslator()->translate($placeholder, $this->getTranslatorTextDomain());
         $element->setAttribute('data-placeholder', $placeholder);
     }
     return parent::render($element);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:9,代码来源:FormSelect.php

示例13: render

 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $class = $element->getAttribute('class');
     if (in_array($this->getType($element), array('submit', 'reset', 'button'))) {
         $class = 'btn' . (empty($class) ? '' : ' ' . $class);
     }
     $element->setAttribute('class', $class);
     return parent::render($element);
 }
开发者ID:athemcms,项目名称:netis,代码行数:16,代码来源:FormInput.php

示例14: 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)
 {
     if (array_key_exists('class', $displayOptions)) {
         $class = $element->getAttribute('class');
         $class = $this->genUtil->addWords($displayOptions['class'], $class);
         $escapeHtmlAttrHelper = $this->getEscapeHtmlAttrHelper();
         $class = $this->genUtil->escapeWords($class, $escapeHtmlAttrHelper);
         $element->setAttribute('class', $class);
     }
     $this->formUtil->addIdAttributeIfMissing($element);
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:18,代码来源:FormPasswordTwb.php

示例15: addScripts

 public function addScripts(ElementInterface $oElement)
 {
     $view = $this->getView();
     $id = $oElement->getAttribute('id');
     $inlinejs = sprintf(self::$inlineSriptFormat, $id);
     $script = $view->inlineScript();
     $headScript = $view->headScript();
     $script->appendScript($inlinejs, 'text/javascript', array('noescape' => true));
     // Disable CDATA comments
     $headScript->appendFile($view->basePath('js/bootstrap-slider.min.js'));
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:11,代码来源:FormSlider.php


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