本文整理匯總了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();
}