當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ElementInterface::setAttributes方法代碼示例

本文整理匯總了PHP中Zend\Form\ElementInterface::setAttributes方法的典型用法代碼示例。如果您正苦於以下問題:PHP ElementInterface::setAttributes方法的具體用法?PHP ElementInterface::setAttributes怎麽用?PHP ElementInterface::setAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Form\ElementInterface的用法示例。


在下文中一共展示了ElementInterface::setAttributes方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: render

    public function render(ElementInterface $element)
    {
        $attributes = $element->getAttributes();
        if (isset($attributes['custom'])) {
            $custom = $attributes['custom'];
            unset($attributes['custom']);
            $element->setAttributes($attributes);
        }
        $prefix = '';
        $suffix = '';

        // Check on name for now
        if ($attributes['type'] === 'text' && $attributes['name'] === 'email') {
            $prefix .= '<div class="input-group">';
            $prefix .= '<span class="input-group-addon">@</span>';
            $suffix .= '<span class="input-group-addon" id="basic-addon2">@example.com</span>';
            $suffix .= '</div>';
        } elseif ($attributes['type'] === 'text' && $attributes['name'] === 'keyword') {
            $prefix .= '<div class="input-group">';
            $suffix .= '<span class="input-group-btn">';
            $suffix .= sprintf('<button class="btn btn-default" type="submit">%s</button>', $custom['label']);
            $suffix .= '</span>';
        }
        return $prefix . parent::render($element) . $suffix;
    }
開發者ID:jbarentsen,項目名稱:drb,代碼行數:25,代碼來源:FormElementHelper.php

示例2: render

 /**
  * Renders the form row as a bootstrap form row
  *
  * @param ElementInterface $element
  * @param null $labelPosition
  * @return string
  */
 public function render(ElementInterface $element, $labelPosition = null)
 {
     if ($element->getAttribute('type') != 'submit') {
         $elementAttributes = $element->getAttributes();
         if (isset($elementAttributes['class']) && $elementAttributes['class'] != null) {
             $elementAttributes['class'] .= ' form-control';
         } else {
             $elementAttributes['class'] = 'form-control';
         }
         $element->setAttributes($elementAttributes);
     }
     $row = parent::render($element, $labelPosition);
     return '<div class="form-group">' . $row . '</div>';
 }
開發者ID:spoorey,項目名稱:hangman,代碼行數:21,代碼來源:BootstrapFormRowHelper.php

示例3: render

 /**
  * @param ElementInterface $element
  * @return string|void
  */
 public function render(ElementInterface $element)
 {
     $twitter = $element->getOption('twitter_date');
     $twitter = empty($twitter) ? array() : $twitter;
     $hasButton = !empty($twitter['has-button']) || !empty($twitter['has_button']);
     unset($twitter['has-button']);
     unset($twitter['has_button']);
     $attrs = $element->getAttributes();
     if ($hasButton) {
         $attrsw = array('class' => 'input-append date', 'id' => 'div-' . $attrs['id']);
         $attrsw = Utils::arrayMergeRecursiveRight($attrsw, $twitter);
         $openW = '<div ' . $this->createAttributesString($attrsw) . '>';
         $closeW = '<span class="add-on"><i class="icon-calendar"></i></span></div>';
     } else {
         $attrs = Utils::arrayMergeRecursiveRight($attrs, $twitter);
         $element->setAttributes($attrs);
         $openW = '';
         $closeW = '';
     }
     return $openW . parent::render($element) . $closeW;
 }
開發者ID:athemcms,項目名稱:netis,代碼行數:25,代碼來源:FormDate.php

示例4: render

 public function render(ElementInterface $element = null)
 {
     /* @var \Zend\View\Renderer\PhpRenderer $view */
     $view = $this->getView();
     /* @var \Zend\View\Helper\HeadScript $headScript */
     $headScript = $view->plugin('headscript');
     /* @var \Zend\View\Helper\BasePath $basePath */
     $basePath = $view->plugin('basePath');
     $params = $view->plugin('params');
     /* @var \Core\View\Helper\Params $params */
     $lang = $params('lang');
     $headScript->appendFile($basePath('/js/bootstrap-datepicker/js/bootstrap-datepicker.min.js'));
     if (in_array($this->language, ['de'])) {
         $headScript->appendFile($basePath('/js/bootstrap-datepicker/locales/bootstrap-datepicker.de.min.js'));
     }
     $element->setAttributes(['data-date-language' => $lang, 'data-provide' => 'datepicker', 'data-date-format' => 'yyyy-mm-dd']);
     $input = parent::render($element);
     /*
      *
      */
     $markup = '<div class="input-group date">%s<div data-toggle="description" data-target="%s" class="input-group-addon" onClick="$(this).parent().find(\':input\').datepicker(\'show\')">' . '<i class="fa fa-calendar"></i></div></div><div class="checkbox"></div>';
     $markup = sprintf($markup, $input, $element->getAttribute('id'));
     return $markup;
 }
開發者ID:cross-solution,項目名稱:yawik,代碼行數:24,代碼來源:FormDatePicker.php

示例5: configureElement

 /**
  * Configure an element based on the provided specification
  *
  * Specification can contain any of the following:
  * - type: the Element class to use; defaults to \Zend\Form\Element
  * - name: what name to provide the element, if any
  * - options: an array, Traversable, or ArrayAccess object of element options
  * - attributes: an array, Traversable, or ArrayAccess object of element
  *   attributes to assign
  *
  * @param  ElementInterface              $element
  * @param  array|Traversable|ArrayAccess $spec
  * @throws Exception\DomainException
  * @return ElementInterface
  */
 public function configureElement(ElementInterface $element, $spec)
 {
     $spec = $this->validateSpecification($spec, __METHOD__);
     $name = isset($spec['name']) ? $spec['name'] : null;
     $options = isset($spec['options']) ? $spec['options'] : null;
     $attributes = isset($spec['attributes']) ? $spec['attributes'] : null;
     if ($name !== null && $name !== '') {
         $element->setName($name);
     }
     if (is_array($options) || $options instanceof Traversable || $options instanceof ArrayAccess) {
         $element->setOptions($options);
     }
     if (is_array($attributes) || $attributes instanceof Traversable || $attributes instanceof ArrayAccess) {
         $element->setAttributes($attributes);
     }
     return $element;
 }
開發者ID:zhangyuxiao,項目名稱:qoros,代碼行數:32,代碼來源:Factory.php


注:本文中的Zend\Form\ElementInterface::setAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。