public function testZeroArraySourceNotOverwrittenByEmptyString() { $source = array(0 => 'zero'); $field = new DropdownField('Field', null, $source); $field->setEmptyString('select...'); $this->assertEquals($field->getSource(), array('' => 'select...', 0 => 'zero')); }
public function testZeroArraySourceNotOverwrittenByEmptyString() { $source = array(0 => 'zero'); $field = new DropdownField('Field', null, $source); $field->setEmptyString('select...'); $this->assertEquals($field->getSource(), array(0 => 'zero')); $options = $this->findOptionElements($field->Field()); $this->assertEquals(2, count($options), 'Two options exist in the markup, one for the source, one for empty'); }
public function getSource() { $source = parent::getSource(); $v = $this->getCustomValue(); if ($v) { $source[$v] = $v; } $v = $this->getFreeTextItem(); if ($v) { $source['_'] = $v; } return $source; }
public function getSource() { if (!is_callable($this->source)) { return parent::getSource(); } if (!($val = $this->depends->Value())) { $source = array(); } else { $source = call_user_func($this->source, $val); } if ($this->getHasEmptyDefault()) { return array('' => $this->getEmptyString()) + (array) $source; } else { return $source; } }
public function getSource() { if (!is_callable($this->source)) { return parent::getSource(); } $val = $this->depends->Value(); if (!$val && !$this->depends->getHasEmptyDefault()) { $dependsSource = array_keys($this->depends->getSource()); $val = isset($dependsSource[0]) ? $dependsSource[0] : null; } if (!$val) { $source = array(); } else { $source = call_user_func($this->source, $val); } if ($this->getHasEmptyDefault()) { return array('' => $this->getEmptyString()) + (array) $source; } else { return $source; } }
/** * Returns the source of the tree, e.g. a list of ID/Title pairs with hierarchical indenation * * @return array */ function getSource() { if (!$this->source) { $this->source = $this->getHierarchy((int) $this->parentID); } return parent::getSource(); }