public function toArray()
 {
     $id = $this->getId();
     $name = $this->getName();
     $selectFrom = new HTML_QuickForm2_Element_Select("_{$name}", array('id' => "{$id}-from") + $this->attributes);
     $selectTo = new HTML_QuickForm2_Element_Select($name, array('id' => "{$id}-to") + $this->attributes);
     $strValues = array_map('strval', $this->values);
     foreach ($this->optionContainer as $option) {
         // We don't do optgroups here
         if (!is_array($option)) {
             continue;
         }
         $value = $option['attr']['value'];
         unset($option['attr']['value']);
         if (in_array($value, $strValues, true)) {
             $selectTo->addOption($option['text'], $value, empty($option['attr']) ? null : $option['attr']);
         } else {
             $selectFrom->addOption($option['text'], $value, empty($option['attr']) ? null : $option['attr']);
         }
     }
     $buttonFromTo = HTML_QuickForm2_Factory::createElement('button', "{$name}_fromto", array('type' => 'button', 'id' => "{$id}-fromto") + (empty($this->data['from_to']['attributes']) ? array() : self::prepareAttributes($this->data['from_to']['attributes'])), array('content' => empty($this->data['from_to']['content']) ? ' >> ' : $this->data['from_to']['content']));
     $buttonToFrom = HTML_QuickForm2_Factory::createElement('button', "{$name}_tofrom", array('type' => 'button', 'id' => "{$id}-tofrom") + (empty($this->data['to_from']['attributes']) ? array() : self::prepareAttributes($this->data['to_from']['attributes'])), array('content' => empty($this->data['to_from']['content']) ? ' << ' : $this->data['to_from']['content']));
     return array('select_from' => $selectFrom->__toString(), 'select_to' => $selectTo->__toString(), 'button_from_to' => $buttonFromTo->__toString(), 'button_to_from' => $buttonToFrom->__toString());
 }
 public function testBug11138()
 {
     $options = array('2' => 'TwoWithoutZero', '02' => 'TwoWithZero');
     $sel = new HTML_QuickForm2_Element_Select('bug11138');
     $sel->loadOptions($options);
     $sel->setValue('02');
     $selHtml = $sel->__toString();
     $this->assertRegExp('!selected="selected"[^>]*>TwoWithZero!', $selHtml);
     $this->assertNotRegExp('!selected="selected"[^>]*>TwoWithoutZero!', $selHtml);
     $sel->toggleFrozen(true);
     $selFrozen = $sel->__toString();
     $this->assertContains('TwoWithZero', $selFrozen);
     $this->assertContains('value="02"', $selFrozen);
     $this->assertNotContains('TwoWithoutZero', $selFrozen);
     $this->assertNotContains('value="2"', $selFrozen);
 }
Beispiel #3
0
 function __toString()
 {
     return Am_Form_Element_EmailLink::decorateWithLink(parent::__toString(), $this);
 }