public function setElement($element) { if (!$element instanceof ZendSelect) { throw new InvalidArgument(sprintf('%s: Element must be instance of Zend\\Form\\Element\\Select, %s given instead', __METHOD__, get_class($element))); } $element->setLabel(''); parent::setElement($element); $str = ''; $label = $this->_element->getLabel(); if ($label) { $str .= sprintf('<option>%s</option>', $this->escaper->escapeHtmlAttr($label)); } foreach ($element->getValueOptions() as $value => $text) { if (is_array($text)) { if (isset($text['options'])) { $label = $value; if (isset($text['label'])) { $label = $text['label']; } $str .= self::newLine(sprintf('<optgroup label="%s">', $this->escaper->escapeHtmlAttr($label))); self::$indCount++; if (isset($text['options'])) { foreach ($text['options'] as $subValue => $subText) { $str .= self::newLine(sprintf('<option value="%s">%s</option>', $this->escaper->escapeHtmlAttr($subValue), $this->translate($subText))); } } self::$indCount--; $str .= self::newLine('</optgroup>'); } } else { $str .= self::newLine(sprintf('<option value="%s">%s</option>', $this->escaper->escapeHtmlAttr($value), $this->translate($text))); } } $this->add($str); }
/** * @see Advertikon\View\Helper\Element::init() */ public function init() { parent::init(); $this->_element->setAttribute('data-error-icon', $this->_errorIcon); $this->_element->setAttribute('data-success-icon', $this->_successIcon); $this->_element->setAttribute('data-error-msg', $this->_errorMsg); $this->_element->setAttribute('data-success-msg', $this->_successMsg); }
/** * @see Advertikon\View\Helper\Element */ public function closeTag() { $str = ''; if ($this->_element->getValue() && $this->_element->getOption('append')) { $str .= self::newLine($this->translate($this->_element->getValue())); } $str .= parent::closeTag(); return $str; }
/** * @see Advertikon\View\Helper\Fieldset::parse() */ public function parse($element, $helper = null) { if (!$element instanceof ZendCollection) { throw new InvalidArgument(sprintf('%s: Parsed element must instance of Zend\\Form\\Element\\Collection, got %s element', __METHOD__, get_class($element))); } parent::parse($element, $helper); $this->add($this->renderTemplate()); return $this; }
/** * @see Advertikon\View\Helper\Element::setElement() */ public function setElement($element) { $show = false; if ($show) { echo '<b>Set Element: ' . $this->_classId . '</b><br>'; } if ($groupId = $element->getOption('group_id')) { if ($show) { echo 'Group iD: ' . $groupId . '<br>'; } /* Group is ROW Element. If gruop does not exist then element is the first in the group */ $group = $this->getGroup($groupId); if (!$group) { $this->_groupId = $groupId; $group = $this; $this->_nextInGroup = false; if ($show) { echo 'Group is new, ID: ' . $this->getGroupId() . '<br>'; } } else { if ($show) { echo 'find group: ' . get_class($group) . ': "' . $group->getClassId() . '"<br>'; } } if ($element->getOption('isMainInGroup')) { if ($show) { echo 'Main in group<br>'; } if ($group === $this) { if ($show) { echo 'Group is this<br>'; } parent::setElement($element); if ($show) { echo 'Set Element on parent class<br>'; } if ($group->_shouldCreateLabel()) { $label = $group->createLabel(); if ($show) { echo 'Create label<br>'; } $group->add(new Label($label), 1); if ($show) { echo 'Add label to group<br>'; } } $group->add(Input::getElementHelper($element)); if ($show) { echo 'Add input element to group<br>'; } } else { if ($show) { echo 'Call set element on group<br>'; } $group->setElement($element); } } else { $group->add(Input::getElementHelper($element)); if ($show) { echo 'Add input element to group<br>'; } } } else { $this->_nextInGroup = false; parent::setElement($element); if ($this->_shouldCreateLabel()) { $label = $this->createLabel(); $this->add(new Label($label)); } $this->add(Input::getElementHelper($element)); } }