本文整理汇总了PHP中DropdownField::getSource方法的典型用法代码示例。如果您正苦于以下问题:PHP DropdownField::getSource方法的具体用法?PHP DropdownField::getSource怎么用?PHP DropdownField::getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DropdownField
的用法示例。
在下文中一共展示了DropdownField::getSource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testZeroArraySourceNotOverwrittenByEmptyString
public function testZeroArraySourceNotOverwrittenByEmptyString()
{
$source = array(0 => 'zero');
$field = new DropdownField('Field', null, $source);
$field->setEmptyString('select...');
$this->assertEquals($field->getSource(), array('' => 'select...', 0 => 'zero'));
}
示例2: testZeroArraySourceNotOverwrittenByEmptyString
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');
}
示例3: getSource
public function getSource()
{
$source = parent::getSource();
$v = $this->getCustomValue();
if ($v) {
$source[$v] = $v;
}
$v = $this->getFreeTextItem();
if ($v) {
$source['_'] = $v;
}
return $source;
}
示例4: getSource
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;
}
}
示例5: getSource
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;
}
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-dependentdropdownfield,代码行数:21,代码来源:DependentDropdownField.php
示例6: getSource
/**
* 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();
}