예제 #1
0
 public function __invoke(Element $element)
 {
     $description = $element->getOption('description');
     if (!$description) {
         return '';
     }
     return sprintf('<div class="zui-description">%s</div>', $this->getView()->translate($description));
 }
예제 #2
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;
 }
예제 #3
0
 public function testGetOption()
 {
     $element = new Element('foo');
     $this->assertNull($element->getOption('foo'));
 }
예제 #4
0
 public function testCanRetrieveSpecificOption()
 {
     $element = new Element('foo');
     $element->setOptions(array('custom' => 'option'));
     $option = $element->getOption('custom');
     $this->assertEquals('option', $option);
 }
예제 #5
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;
 }