コード例 #1
0
ファイル: FormElementHelper.php プロジェクト: jbarentsen/drb
    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;
    }
コード例 #2
0
 /**
  * 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>';
 }
コード例 #3
0
ファイル: FormDate.php プロジェクト: athemcms/netis
 /**
  * @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;
 }
コード例 #4
0
 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;
 }
コード例 #5
0
ファイル: Factory.php プロジェクト: zhangyuxiao/qoros
 /**
  * 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;
 }