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