Ejemplo n.º 1
0
 /**
  * @param Element $element
  * @param string  $addToClass
  *
  * @return string
  */
 public function getValidationClass(Element $element, $addToClass = '')
 {
     if (!$this->hasValidated) {
         return $addToClass;
     }
     $addToClass = $addToClass ? $addToClass . ' ' : '';
     if ($element->getMessages()) {
         return $addToClass . 'has-error';
     }
     return $addToClass . 'has-success';
 }
Ejemplo n.º 2
0
 public function __invoke(\Zend\Form\Element $e, $keyClasses = null)
 {
     $classes = $this->permanentClasses;
     $messages = $e->getMessages();
     if (!empty($messages)) {
         if (!$keyClasses) {
             $keyClasses = $this->defaultKeyClasses;
         }
         if (!isset($this->classes[$keyClasses])) {
             throw new \RuntimeException(sprintf('A chave \'%s\' não existe no atributo $classes da Helper %s', $keyClasses, __CLASS__));
         }
         $classes .= ' ' . $this->classes[$keyClasses];
     }
     return $classes;
 }
Ejemplo n.º 3
0
 /**
  * __invoke
  *
  * @param Element $formElement
  * @param         $instanceConfig
  *
  * @return string
  */
 public function getHtml(Element $formElement, $instanceConfig)
 {
     $labelName = $inputId = $formElement->getAttribute('name');
     $fieldSetParts = explode('[', $labelName);
     /**
      * Handle elements that came from fieldSets
      */
     if (count($fieldSetParts) > 1) {
         $fieldSetParts = explode(']', $fieldSetParts[1]);
         $labelName = $fieldSetParts[0] . $fieldSetParts[1];
         $inputId = $fieldSetParts[0];
     }
     $instanceConfigLabelName = $labelName . 'Label';
     $text = $instanceConfig[$instanceConfigLabelName];
     return '<label for="' . $inputId . '"' . (count($formElement->getMessages()) ? ' class=invalid' : '') . ' data-textEdit="' . $instanceConfigLabelName . '">' . $text . '</label>';
 }
Ejemplo n.º 4
0
 public function __invoke(Element $element)
 {
     $messages = $element->getMessages();
     $out = '<div class="control-group';
     if (count($messages)) {
         $out .= ' error';
     }
     $out .= '">';
     $element->setLabelAttributes(array('class' => 'control-label'));
     $out .= $this->view->formLabel($element);
     $out .= '<div class="controls">';
     if ($element instanceof \Zend\Form\Element\Radio) {
         $element->setLabelAttributes(array('class' => 'radio'));
     }
     $out .= $this->view->formElement($element);
     $out .= $this->view->formElementErrors()->setMessageOpenFormat('<div class="help-inline">')->setMessageSeparatorString('. ')->setMessageCloseString('.</div>')->render($element);
     $out .= '</div>';
     $out .= '</div>';
     return $out;
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function getMessages()
 {
     return $this->element->getMessages();
 }
Ejemplo n.º 6
0
 public function renderElement(Element $element)
 {
     $element->setLabelAttributes(array('class' => 'sr-only'));
     $element->setAttribute('class', 'form-control');
     $labelHelper = $this->view->plugin('form_label');
     $elementHelper = $this->getElementHelper();
     $elementXhtml = '%1$s';
     if ($element->getMessages() && !$element instanceof \Zend\Form\Element\Collection) {
         $elementXhtml = '<div class="input-group"><span data-toggle="tooltip" data-placement="bottom" class="input-group-addon" data-html="true" title="%2$s"><i class="fa-warning fa"></i></span>%1$s</div>';
     }
     $output = '<div class="form-group%3$s">%1$s%2$s</div>';
     return sprintf($output, $labelHelper($element), sprintf($elementXhtml, $elementHelper($element), $this->view->formElementErrors($element)), $element->getMessages() ? ' has-error' : '');
 }