コード例 #1
0
ファイル: Select.php プロジェクト: advertikon/advertikon
 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);
 }
コード例 #2
0
ファイル: Row.php プロジェクト: advertikon/advertikon
 /**
  * @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));
     }
 }