/** * {@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; }
/** * Put together the colorpicker component. * * @param Zend\Form\Element $element */ protected function assembleComponent($element) { $options = $this->getOptions(); $element = parent::__invoke($element); $component = sprintf('<div style="padding: 0;" class="input-append color %s" data-color="%s" data-color-format="%s">%s', $options['class'], $options['color'], $options['format'], $element) . sprintf('<span class="add-on"><i style="background-color: %s;"></i></span></div>', $options['color']); return $component; }
/** * 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); }
/** * 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); }
/** * @param ElementInterface|null $element * @return Helper\FormInput */ public function input(ElementInterface $element = null) { $helper = new Helper\FormInput(); return $helper->__invoke($element); }