示例#1
0
 protected function createElement(ZendElement $element, $attr = array())
 {
     if ($element instanceof Element && $element->getAttribute('type') == 'hidden') {
         return parent::createElement($element, $attr);
     }
     return '<div class="controls">' . parent::createElement($element, $attr) . '</div>';
 }
示例#2
0
 /**
  * Override: retrieve a single element attribute
  *
  * Retrieves validator hash when asked for 'value' attribute;
  * otherwise, proxies to parent.
  *
  * @param  string $name
  * @return mixed
  */
 public function getAttribute($name)
 {
     if ($name != 'value') {
         return parent::getAttribute($name);
     }
     $validator = $this->getValidator();
     return $validator->getHash();
 }
示例#3
0
 /**
  * __invoke
  *
  * @param Element $formElement
  * @param         $instanceConfig
  *
  * @return string
  */
 public function getHtml(Element $formElement, $instanceConfig)
 {
     $labelName = $inputId = $formElement->getAttribute('name');
     $fieldSetParts = explode('[', $labelName);
     /**
      * Handle elements that came from fieldSets
      */
     if (count($fieldSetParts) > 1) {
         $fieldSetParts = explode(']', $fieldSetParts[1]);
         $labelName = $fieldSetParts[0] . $fieldSetParts[1];
         $inputId = $fieldSetParts[0];
     }
     $instanceConfigLabelName = $labelName . 'Label';
     $text = $instanceConfig[$instanceConfigLabelName];
     return '<label for="' . $inputId . '"' . (count($formElement->getMessages()) ? ' class=invalid' : '') . ' data-textEdit="' . $instanceConfigLabelName . '">' . $text . '</label>';
 }
示例#4
0
 public function testSettingNameSetsNameAttribute()
 {
     $element = new Element();
     $element->setName('foo');
     $this->assertEquals('foo', $element->getAttribute('name'));
 }
示例#5
0
 /**
  * @inheritdoc
  */
 public function getAttribute($key)
 {
     return $this->element->getAttribute($key);
 }
示例#6
0
 /**
  * Add elements view model to a parent view model
  * @param Element   $element
  * @param ViewModel $parentViewModel
  */
 protected function addElementViewModel(Element $element, ViewModel &$parentViewModel)
 {
     $elementViewModel = new ViewModel();
     $type = 'text';
     if ($element->getAttribute('type')) {
         $type = strtolower($element->getAttribute('type'));
     }
     $elementTemplate = 'form/element/' . $type;
     $elementViewModel->setTemplate($elementTemplate);
     $elementViewModel->setVariable('element', $element);
     $parentViewModel->addChild($elementViewModel, 'elements', true);
 }