Esempio n. 1
0
 /**
  * Retrieve the FormLabel helper
  *
  * @return FormLabel
  */
 protected function getLabelHelper()
 {
     if ($this->labelHelper) {
         return $this->labelHelper;
     }
     if (method_exists($this->view, 'plugin')) {
         $this->labelHelper = $this->view->plugin('form_label');
     }
     if (!$this->labelHelper instanceof FormLabel) {
         $this->labelHelper = new FormLabel();
     }
     if ($this->hasTranslator()) {
         $this->labelHelper->setTranslator($this->getTranslator(), $this->getTranslatorTextDomain());
     }
     return $this->labelHelper;
 }
Esempio n. 2
0
 /**
  * Create a string of all attribute/value pairs
  *
  * Escapes all attribute values
  *
  * @param  array $attributes
  * @return string
  */
 public function createAttributesString(array $attributes)
 {
     if (isset($attributes['class'])) {
         $attributes['class'] = trim($attributes['class'] . ' ' . $this->cssClass);
     } else {
         $attributes['class'] = $this->cssClass;
     }
     return parent::createAttributesString($attributes);
 }
Esempio n. 3
0
 /**
  * Generate an opening label tag
  * @param  null|array|ElementInterface $attributesOrElement
  * @return string
  */
 public function openTag($attributesOrElement = null)
 {
     $labelAttributes = array();
     if (is_array($attributesOrElement)) {
         $labelAttributes = $attributesOrElement;
     }
     if ($attributesOrElement instanceof LabelOptionsAwareInterface) {
         $labelAttributes = $attributesOrElement->getLabelAttributes();
     }
     $labelAttributes['class'] = 'control-label' . (empty($labelAttributes['class']) ? '' : ' ' . $labelAttributes['class']);
     return parent::openTag($labelAttributes);
 }
Esempio n. 4
0
 /**
  * Set Label Helper.
  *
  * @param \Zend\Form\View\Helper\FormLabel $labelHelper
  *
  * @return self
  */
 public function setLabelHelper(FormLabel $labelHelper)
 {
     $labelHelper->setView($this->getView());
     $this->labelHelper = $labelHelper;
     return $this;
 }
 /**
  * Label
  *
  * @param ElementInterface|null $element
  * @param null $labelContent
  * @param null $position
  * @return string|Helper\FormLabel
  */
 public function label(ElementInterface $element = null, $labelContent = null, $position = null)
 {
     $helper = new Helper\FormLabel();
     return $helper->__invoke($element, $labelContent, $position);
 }
Esempio n. 6
0
 /**
  * @param ElementInterface|null $element
  * @param null $labelContent
  * @param null $position
  * @return string|OriginalFormLabel
  */
 public function __invoke(ElementInterface $element = null, $labelContent = null, $position = null)
 {
     $this->element = $element;
     return parent::__invoke($element, $labelContent, $position);
 }