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>'; }
/** * 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(); }
/** * __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>'; }
public function testSettingNameSetsNameAttribute() { $element = new Element(); $element->setName('foo'); $this->assertEquals('foo', $element->getAttribute('name')); }
/** * @inheritdoc */ public function getAttribute($key) { return $this->element->getAttribute($key); }
/** * 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); }