Exemplo n.º 1
0
 public function getViewHelperConfig()
 {
     return array('factories' => array('formRow' => function ($sm) {
         $helper = new FormRow();
         $helper->setRenderErrors(false);
         return $helper;
     }), 'invokables' => array('administrationMenu' => 'Blog\\View\\Helper\\AdministrationMenu'));
 }
Exemplo n.º 2
0
 public function getViewHelperConfig()
 {
     return array('factories' => array('formRow' => function ($sm) {
         $helper = new FormRow();
         $helper->setRenderErrors(true);
         return $helper;
     }));
 }
Exemplo n.º 3
0
 public function render(ElementInterface $element)
 {
     if (in_array($element->getAttribute('type'), array('html'))) {
         return $element->getValue();
     }
     return parent::render($element);
 }
Exemplo n.º 4
0
 /**
  * Utility form helper that renders a label (if it exists), an element and errors
  *
  * @param  ElementInterface $element
  * @throws \Zend\Form\Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     $elementType = substr(get_class($element), strrpos(get_class($element), '\\') + 1);
     $elementTypeClass = 'form-row-' . strtolower($elementType);
     $elementRowId = lcfirst($element->getAttribute('name')) . '-row';
     $html = '<div id="' . $elementRowId . '" class="form-row ' . $elementTypeClass . '">';
     $html .= parent::render($element);
     $html .= '</div>';
     return $html;
 }
Exemplo n.º 5
0
 /**
  * Handles the options title, tooltip, and description for elements
  *
  *
  * @param ElementInterface $element
  * @param null $labelPosition
  * @return string
  */
 function render(ElementInterface $element, $labelPosition = null)
 {
     $markup = parent::render($element, $labelPosition);
     $options = $element->getOptions();
     $markupplus = '<div class="formrowplus" %s>%s%s%s</div>';
     $title = isset($options['title']) ? '<h4 class="title">' . $options['title'] . '</h4>' : '';
     $description = isset($options['description']) ? '<p class="description">' . $options['description'] . '</p>' : '';
     $tooltip = isset($options['tooltip']) ? ' tooltip="' . $options['tooltip'] . '"' : '';
     $markup = sprintf($markupplus, $title, $tooltip, $description);
     return $markup;
 }
 /**
  * @inheritdoc
  */
 public function render(ElementInterface $element, $labelPosition = null)
 {
     $wrapper = '<div class="col-md-12">%s</div>';
     if ($element->getAttribute('type') == 'multi_checkbox') {
         $wrapper = '<div class="col-md-2">%s</div>';
         if ($this->count == 6) {
             $wrapper .= ' <div class="clearfix visible-lg-block"></div>';
             $this->count = 0;
         }
         $this->count = $this->count + 1;
     }
     return sprintf($wrapper, parent::render($element));
 }
Exemplo n.º 7
0
 /**
  *
  * @see FormRow::render()
  * @param ElementInterface $oElement        	
  * @return string
  */
 public function render(ElementInterface $oElement, $labelPosition = null)
 {
     $sElementType = $oElement->getAttribute('type');
     // Nothing to do for hidden elements which have no messages
     if ($sElementType === 'hidden' && !$oElement->getMessages()) {
         return parent::render($oElement);
     }
     // Retrieve expected layout
     $sLayout = $oElement->getOption('layout');
     // Partial rendering
     if ($this->partial) {
         return $this->view->render($this->partial, array('element' => $oElement, 'label' => $this->renderLabel($oElement), 'labelAttributes' => $this->labelAttributes, 'labelPosition' => $this->labelPosition, 'renderErrors' => $this->renderErrors));
     }
     $sRowClass = '';
     if (($fgs = $oElement->getOption('form-group-size')) != false) {
         $sRowClass = $fgs;
     }
     // Validation state
     if (($sValidationState = $oElement->getOption('validation-state')) != false) {
         $sRowClass .= ' has-' . $sValidationState;
     }
     // "has-error" validation state case
     if ($oElement->getMessages()) {
         $sRowClass .= ' has-error';
         // Element have errors
         if (($sInputErrorClass = $this->getInputErrorClass()) != false) {
             if (($sElementClass = $oElement->getAttribute('class')) != false) {
                 if (!preg_match('/(\\s|^)' . preg_quote($sInputErrorClass, '/') . '(\\s|$)/', $sElementClass)) {
                     $oElement->setAttribute('class', trim($sElementClass . ' ' . $sInputErrorClass));
                 }
             } else {
                 $oElement->setAttribute('class', $sInputErrorClass);
             }
         }
     }
     // Column size
     if (($sColumSize = $oElement->getOption('column-size')) && $sLayout !== LeadFilterForm::LAYOUT_HORIZONTAL) {
         $sRowClass .= ' col-' . $sColumSize;
     }
     // Render element
     $sElementContent = $this->renderElement($oElement);
     // Render form row
     if ($sElementType === 'checkbox' && $sLayout !== LeadFilterForm::LAYOUT_HORIZONTAL) {
         return $sElementContent . PHP_EOL;
     }
     if (($sElementType === 'submit' || $sElementType === 'button' || $sElementType === 'reset') && $sLayout === LeadFilterForm::LAYOUT_INLINE) {
         return $sElementContent . PHP_EOL;
     }
     return sprintf(self::$formGroupFormat, $sRowClass, $sElementContent) . PHP_EOL;
 }
Exemplo n.º 8
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>';
 }
Exemplo n.º 9
0
 /**
  * @see FormRow::render()
  * @param ElementInterface $oElement
  * @return string
  */
 public function render(ElementInterface $oElement, $sLabelPosition = null)
 {
     // Retrieve element type
     $sElementType = $oElement->getAttribute('type');
     // Nothing to do for hidden elements which have no messages
     if ($sElementType === 'hidden' && !$oElement->getMessages()) {
         return parent::render($oElement, $sLabelPosition);
     }
     // Retrieve expected layout
     $sLayout = $oElement->getOption('bootstrap-layout');
     // Define label position
     if ($sLabelPosition === null) {
         $sLabelPosition = $this->getLabelPosition();
     }
     // Partial rendering
     if ($this->partial) {
         return $this->view->render($this->partial, array('element' => $oElement, 'label' => $this->renderLabel($oElement), 'labelAttributes' => $this->labelAttributes, 'labelPosition' => $sLabelPosition, 'renderErrors' => $this->renderErrors));
     }
     // "has-error" validation state case
     if ($oElement->getMessages()) {
         //Element have errors
         if ($sInputErrorClass = $this->getInputErrorClass()) {
             if ($sElementClass = $oElement->getAttribute('class')) {
                 if (!preg_match('/(\\s|^)' . preg_quote($sInputErrorClass, '/') . '(\\s|$)/', $sElementClass)) {
                     $oElement->setAttribute('class', trim($sElementClass . ' ' . $sInputErrorClass));
                 }
             } else {
                 $oElement->setAttribute('class', $sInputErrorClass);
             }
         }
     }
     // Render element
     $sElementContent = $this->renderElement($oElement, $sLabelPosition);
     // Render form row
     switch (true) {
         // Checkbox element not in horizontal form
         case $sElementType === 'checkbox' && $sLayout !== Form::LAYOUT_HORIZONTAL && !$oElement->getOption('form-group'):
             // All "button" elements in inline form
         // All "button" elements in inline form
         case in_array($sElementType, array('submit', 'button', 'reset'), true) && $sLayout === Form::LAYOUT_INLINE:
             return $sElementContent . PHP_EOL;
         default:
             // Render element into form group
             return $this->renderElementFormGroup($sElementContent, $this->getRowClassFromElement($oElement));
     }
 }
Exemplo n.º 10
0
 public function render(ElementInterface $element)
 {
     // Error helper
     $elementErrorsHelper = $this->getElementErrorsHelper();
     $elementErrorsHelper->setMessageOpenFormat('<small>');
     $elementErrorsHelper->setMessageCloseString('</small>');
     $elementErrorsHelper->setMessageSeparatorString('<br>');
     $elementErrors = $elementErrorsHelper->render($element);
     // Add CSS class if the element has errors
     $attributes = null;
     if (!empty($elementErrors)) {
         $attributes = $this->createAttributesString(array('class' => 'error'));
     }
     // Append no errors!
     $this->setRenderErrors(false);
     // Render label with element
     $markup = sprintf('<div%s>%s%s</div>', null !== $attributes ? ' ' . $attributes : '', parent::render($element), $elementErrors);
     return $markup;
 }
Exemplo n.º 11
0
    public function render(ElementInterface $element)
    {
        $inputErrorClass = '';

        // Does this element have errors ?
        if (count($element->getMessages()) > 0) {
            $inputErrorClass = ' has-error';
        }

        $type = $element->getAttribute('type');

        if ($type != 'checkbox') {
            return '<div class="form-group' . $inputErrorClass . '">' . parent::render($element) . '</div>';
        }

        $prefix = '<div class="form-group' . $inputErrorClass . '"><div class="col-sm-offset-2 col-sm-5"><div class="checkbox">';

        $postfix = '</div></div></div>';

        return $prefix . parent::render($element) . $postfix;
    }
Exemplo n.º 12
0
 /**
  * {@inheritDoc}
  */
 protected function getElementHelper()
 {
     if ($this->getRenderMode() === self::RENDER_STATIC) {
         return $this->getStaticElementHelper();
     }
     return parent::getElementHelper();
 }
Exemplo n.º 13
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $helper = new FormRow();
     $helper->setPartial('basic/form-row.phtml');
     return $helper;
 }