/**
  * render
  *
  * Render the checkbox HTML.
  *
  * @param  ElementInterface  $element  The element that should be rendered.
  *
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $html = parent::render($element);
     $attributes = ['class' => 'checkbox'];
     $escapeHtml = $this->getEscapeHtmlHelper();
     return sprintf('<div %s><label for="%s">%s%s</label></div>', $this->createAttributesString($attributes), $element->hasAttribute('id') ? $element->getAttribute('id') : $element->getName(), $html, $escapeHtml($element->getOption('label')));
 }
Esempio n. 2
0
 /**
  * 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;
 }
 /**
  * Render a form <input> checkbox element from the provided $element,
  * @param  ElementInterface $element
  * @param  null|string $formType
  * @param  array $displayOptions
  * @return string
  */
 public function render(ElementInterface $element, $formType = null, array $displayOptions = array())
 {
     $this->prepareElementBeforeRendering($element, $formType, $displayOptions);
     $html = parent::render($element);
     //Wrap the simple checkbox into label for proper rendering
     $html = '<label class="checkbox">' . $html . '</label>';
     return $html;
 }
Esempio n. 4
0
 /**
  * {@inheritDoc}
  */
 public function render(ElementInterface $element)
 {
     if ($element instanceof LabelAwareInterface) {
         if ($element->getLabelOption('always_wrap') !== false) {
             $element->setLabelOption('always_wrap', true);
         }
     }
     return parent::render($element);
 }
 public function render(ElementInterface $element)
 {
     $input = parent::render($element);
     $translator = $this->getTranslator();
     $textDomain = $this->getTranslatorTextDomain();
     $label = $element->getLabel();
     $desc = $element->getOption('description');
     if ($label) {
         $label = $translator->translate($label, $textDomain);
     }
     /*
     * 'label' => *@translate* 'Privacy Police',
            'description' => /*@translate* 'I have read the %s and accept it',
            'linktext' => /*@translate* 'privacy police',
            'route' => 'lang/applications/disclaimer',
     */
     if ($desc) {
         $desc = $translator->translate($desc, $textDomain);
         $linktext = $element->getOption('linktext');
         $route = $element->getOption('route');
         $params = $element->getOption('params');
         if ($linktext) {
             if ($route) {
                 if (!$params) {
                     $params = array();
                 }
                 $href = $this->getView()->url($route, $params, true);
             } else {
                 /*@todo add more options like providing url... */
                 $href = "";
             }
             $linktext = $translator->translate($linktext);
             $link = '<a data-toggle="modal" href="' . $href . '" ' . 'data-target="#modal-' . $element->getAttribute('id') . '">' . $linktext . '</a>';
             $desc = sprintf($desc, $link);
         }
         $label = '<h6>' . $label . '</h6>';
     } else {
         $desc = $label;
         $label = '';
     }
     $markup = '
     <div class="form-checkbox-wrapper">
         <div class="pull-left">%s</div>
         <div class="form-checkbox-label"><label for="%s">%s</label></div>
     </div>
     
     <div class="modal fade" id="modal-' . $element->getAttribute('id') . '">
         <div class="modal-dialog modal-lg">
             <div class="modal-content">
             </div>
         </div>
     </div>';
     $markup = sprintf($markup, $input, $element->getAttribute('id'), $desc);
     return $label . $markup;
 }
Esempio n. 6
0
 /**
  * Render a form <input> element from the provided $element
  *
  * @param  ElementInterface $element
  * @throws Exception\InvalidArgumentException
  * @throws Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $markup = parent::render($element);
     if ($element instanceof Checkbox && ($labelEnable = $element->getLabelEnable())) {
         if ($this->hasTranslator()) {
             $labelEnable = $this->getTranslator()->translate($labelEnable, strstr($labelEnable, '.', true));
         }
         $helper = $this->getLabelHelper();
         $markup = $helper->openTag($element->getLabelEnableAttributes()) . $markup . $labelEnable . $helper->closeTag();
     }
     return $markup;
 }
Esempio n. 7
0
 public function render(ElementInterface $element)
 {
     $input = parent::render($element);
     $translator = $this->getTranslator();
     $textDomain = $this->getTranslatorTextDomain();
     $label = $element->getOption('long_label');
     $headline = $element->getOption('headline');
     if ($label) {
         $label = $translator->translate($label, $textDomain);
         $linktext = $element->getOption('linktext');
         $route = $element->getOption('route');
         $params = $element->getOption('params');
         if ($linktext) {
             if ($route) {
                 if (!$params) {
                     $params = array();
                 }
                 /** @noinspection PhpUndefinedMethodInspection */
                 $href = $this->getView()->url($route, $params, true);
             } else {
                 /*@todo add more options like providing url... */
                 $href = "";
             }
             $linktext = $translator->translate($linktext);
             $link = '<a data-toggle="modal" href="' . $href . '" ' . 'data-target="#modal-' . $element->getAttribute('id') . '">' . $linktext . '</a>';
             $label = sprintf($label, $link);
         }
     }
     if ($headline) {
         $headline = '<h6>' . $translator->translate($headline, $textDomain) . '</h6>';
     }
     $markup = '
     <div class="checkbox">
         <label for="%s">%s %s</label>
     </div>
     <div class="modal fade modal-scrollable" id="modal-' . $element->getAttribute('id') . '" tabindex="-1" role="dialog" aria-labelledby="label-search-user" aria-hidden="true">
         <div class="modal-dialog modal-lg">
             <div class="modal-content">
             </div>
         </div>
     </div>';
     $markup = sprintf($markup, $element->getAttribute('id'), $input, $label);
     return $headline . $markup;
 }
 /**
  * @see \Zend\Form\View\Helper\FormCheckbox::render()
  * @param \Zend\Form\ElementInterface $oElement
  * @throws \LogicException
  * @throws \InvalidArgumentException
  * @return string
  */
 public function render(\Zend\Form\ElementInterface $oElement)
 {
     if ($oElement->getOption('disable-twb')) {
         return parent::render($oElement);
     }
     if (!$oElement instanceof \Zend\Form\Element\Checkbox) {
         throw new \InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Checkbox', __METHOD__));
     }
     if (($sName = $oElement->getName()) !== 0 && empty($sName)) {
         throw new \LogicException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $aAttributes = $oElement->getAttributes();
     $aAttributes['name'] = $sName;
     $aAttributes['type'] = $this->getInputType();
     $aAttributes['value'] = $oElement->getCheckedValue();
     $sClosingBracket = $this->getInlineClosingBracket();
     if ($oElement->isChecked()) {
         $aAttributes['checked'] = 'checked';
     }
     //Render label
     $sLabelOpen = $sLabelClose = $sLabelContent = '';
     //Render label and visible element
     if ($sLabelContent = $oElement->getLabel()) {
         if ($oTranslator = $this->getTranslator()) {
             $sLabelContent = $oTranslator->translate($sLabelContent, $this->getTranslatorTextDomain());
         }
         $oLabelHelper = $this->getLabelHelper();
         $sLabelOpen = $oLabelHelper->openTag($oElement->getLabelAttributes() ?: null);
         $sLabelClose = $oLabelHelper->closeTag();
     }
     //Render checkbox
     $sElementContent = sprintf('<input %s%s', $this->createAttributesString($aAttributes), $sClosingBracket);
     //Add label markup
     if ($this->getLabelPosition($oElement) === \Zend\Form\View\Helper\FormRow::LABEL_PREPEND) {
         $sElementContent = $sLabelOpen . ($sLabelContent ? rtrim($sLabelContent) . ' ' : '') . $sElementContent . $sLabelClose;
     } else {
         $sElementContent = $sLabelOpen . $sElementContent . ($sLabelContent ? ' ' . ltrim($sLabelContent) : '') . $sLabelClose;
     }
     //Render hidden input
     if ($oElement->useHiddenElement()) {
         $sElementContent = sprintf('<input type="hidden" %s%s', $this->createAttributesString(array('name' => $aAttributes['name'], 'value' => $oElement->getUncheckedValue())), $sClosingBracket) . $sElementContent;
     }
     return $sElementContent;
 }
Esempio n. 9
0
 /**
  * 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)
 {
     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('');
     }
     $value = $element->getValue();
     $checkedBoole = $value == 1 || $value == 'on';
     $checkedClass = $checkedBoole ? 'active"' : '';
     $hiddenElement = '';
     if ($element->useHiddenElement()) {
         $hiddenAttributes = ['name' => $element->getName(), 'value' => $element->getUncheckedValue()];
         $hiddenElement = sprintf('<input type="hidden" %s%s', $this->createAttributesString($hiddenAttributes), '>');
         $element->setUseHiddenElement(false);
     }
     $buttonContent = $hiddenElement . PHP_EOL . '<div class="btn-group" data-toggle="buttons">' . PHP_EOL . '<label class="btn btn-default ' . $checkedClass . '">' . PHP_EOL . parent::render($element) . $buttonContent . PHP_EOL . '</label>' . PHP_EOL . '</div>' . PHP_EOL;
     return $buttonContent;
 }
 public function renderBare(ElementInterface $element)
 {
     return parent::render($element);
 }
Esempio n. 11
0
 public function render(ElementInterface $element)
 {
     $element->setAttribute('class', 'checkbox-toggle');
     return parent::render($element);
 }
 /**
  * Checkbox
  *
  * @param ElementInterface|null $element
  * @return string|Helper\FormInput
  */
 public function checkbox(ElementInterface $element = null)
 {
     $helper = new Helper\FormCheckbox();
     return $helper->__invoke($element);
 }
 public function render(ElementInterface $element)
 {
     return $this->openTag($element) . parent::render($element) . $this->closeTag();
 }