예제 #1
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;
 }
예제 #2
0
 /**
  * Render element label
  *
  * @param  \Zend\Form\Element $element
  * @param  \Zend\View\Renderer $view
  * @return string
  */
 public function renderLabel(Form\Element $element, View $view)
 {
     $label = $element->getLabel();
     if (empty($label)) {
         $label = $element->getName();
     }
     return $this->getMarkupElementLabelStart() . $view->vars()->escape($label) . $this->getMarkupElementLabelEnd();
 }
예제 #3
0
 /**
  * Get value
  *
  * If element type is one of the button types, returns the label.
  *
  * @param  \Zend\Form\Element $element
  * @return string|null
  */
 public function getValue($element)
 {
     if (!$element instanceof Element) {
         return null;
     }
     foreach ($this->_buttonTypes as $type) {
         if ($element instanceof $type) {
             if (stristr($type, 'button')) {
                 $element->content = $element->getLabel();
                 return null;
             }
             return $element->getLabel();
         }
     }
     return $element->getValue();
 }
예제 #4
0
 public function testPassingConfigObjectToConstructorSetsObjectState()
 {
     $config = new Config($this->getOptions());
     $element = new Element($config);
     $this->assertEquals('changed', $element->getName());
     $this->assertEquals('foo', $element->getValue());
     $this->assertEquals('bar', $element->getLabel());
     $this->assertEquals(50, $element->getOrder());
     $this->assertFalse($element->isRequired());
     $this->assertEquals('bar', $element->foo);
     $this->assertEquals('bat', $element->baz);
 }
예제 #5
0
 /**
  * @inheritdoc
  */
 public function getLabel()
 {
     return $this->element->getLabel();
 }
예제 #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 createLabel(Element $form, $attr = array())
 {
     return '<legend>' . $form->getLabel() . '</legend>';
 }