예제 #1
0
 public function testCanRenderRowLabelAttributes()
 {
     $element = new Element('foo');
     $element->setLabel('The value for foo:');
     $element->setLabelAttributes(array('class' => 'bar'));
     $this->helper->setLabelPosition('append');
     $markup = $this->helper->render($element);
     $this->assertContains("<label class=\"bar\">", $markup);
 }
 /**
  * Renders the control label for the Bootstrap control group
  *
  * @param Element $element
  * @return string
  */
 public function renderLabel(Element $element)
 {
     $label = '';
     //Get the right class
     $element->setLabelAttributes($this->setLabelClasses($element));
     //Only add the class to the label if it is one of the control elements
     if ($this->isControl($element) || $this->isRadio($element)) {
         $label = $this->getView()->formLabel($element);
     }
     //Only control elements, multi-checkboxes, & radios have a label that appears outside of the control group
     return $label;
 }
예제 #3
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;
 }
예제 #4
0
 /**
  * Outputs message depending on flag
  *
  * @return string
  */
 public function __invoke(Element $element)
 {
     $element->setLabelAttributes(array('class' => 'control-label'));
     $element->setAttribute('data-placement', 'bottom')->setAttribute('data-content', $element->getOption('description'));
     if (!$element->getLabel()) {
         $element->setLabel('öö');
     }
     $output = '<div class="control-group">';
     $output .= $this->getView()->formLabel($element);
     $output .= '<div class="controls">';
     $output .= $this->getView()->formElement($element);
     if ($element->getOption('description')) {
         $output .= '<div class="description">' . $element->getOption('description') . '</div>';
     }
     if ($element->getMessages()) {
         $output .= '<div class="alert alert-error">' . $this->getView()->formElementErrors($element) . '</div>';
     }
     $output .= '</div>';
     $output .= '</div>';
     return $output;
 }
예제 #5
0
 public function testsetLabelAttributes()
 {
     $element = new Element('foo');
     $element->setLabel('The value for foo:');
     $element->setLabelAttributes(array('id' => 'bar'));
     $markup = $this->helper->__invoke($element, '<input type="text" id="foo" />', FormLabelHelper::APPEND);
     $this->assertContains('"foo" />The value for foo:</label>', $markup);
     $this->assertContains('id="bar" for="foo"', $markup);
     $this->assertContains('<label', $markup);
     $this->assertContains('><input type="text" id="foo" />', $markup);
 }
예제 #6
0
 /**
  * @param Zend\Form\Element $element
  *
  * @return string
  */
 protected function getElement(Element $element)
 {
     $element->setLabelAttributes(array('class' => 'control-label col-sm-2'));
     $element->setAttribute('data-placement', 'bottom')->setAttribute('class', 'form-control')->setAttribute('data-content', $element->getOption('description'))->setAttribute('data-trigger', 'focus');
     if (!$element->getLabel()) {
         $element->setLabel('öö');
     }
     $output = sprintf('<div class="form-group%1$s">', $element->getMEssages() && !$element instanceof \Zend\Form\Element\Collection ? ' has-error' : '');
     $output .= $this->getView()->formLabel($element);
     $output .= '<div class="col-sm-10">';
     if ($element->getMessages() && !$element instanceof \Zend\Form\Element\Collection) {
         $output .= sprintf('<div class="input-group"><span data-toggle="tooltip" data-placement="bottom" class="input-group-addon" data-html="true" title="%1$s"><i class="fa-warning fa"></i></span>', $this->getView()->formElementErrors($element));
     }
     if ($element instanceof \Zend\Form\Element\Collection) {
         $output .= $this->getView()->formCollection($element);
     } else {
         $output .= $this->getView()->formElement($element);
     }
     if ($element->getMessages()) {
         $output .= '</div>';
     }
     $output .= '</div>';
     $output .= '</div>';
     return $output;
 }
예제 #7
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' : '');
 }