mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API-CHANGE: SSF-30 adding a method to control a parameter passed to Hierarchy->getChildrenAsUL() from TreeDropdownField. The parameter is useful for controlling whether the returned UL contains child nodes, or just folders.
This commit is contained in:
parent
13c7c01b95
commit
5967a1c135
@ -54,6 +54,7 @@ class TreeDropdownField extends FormField {
|
|||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
protected $sourceObject, $keyField, $labelField, $filterCallback, $searchCallback, $baseID = 0;
|
protected $sourceObject, $keyField, $labelField, $filterCallback, $searchCallback, $baseID = 0;
|
||||||
|
protected $childrenMethod = 'AllChildrenIncludingDeleted'; //default child method in Hierarcy->getChildrenAsUL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by field search to leave only the relevant entries
|
* Used by field search to leave only the relevant entries
|
||||||
@ -143,6 +144,16 @@ class TreeDropdownField extends FormField {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $method The parameter to ChildrenMethod to use when calling Hierarchy->getChildrenAsUL in {@link Hierarchy}.
|
||||||
|
* The method specified determined the structure of the returned list. Use "ChildFolders" in place of the default
|
||||||
|
* to get a drop-down listing with only folders, i.e. not including the child elements in the currently selected folder.
|
||||||
|
* See {@link Hierarchy} for a complete list of possible methods.
|
||||||
|
*/
|
||||||
|
public function setChildrenMethod($method) {
|
||||||
|
$this->childrenMethod = $method;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -244,11 +255,11 @@ class TreeDropdownField extends FormField {
|
|||||||
}
|
}
|
||||||
$eval = '"<li id=\"selector-' . $this->getName() . '-{$child->' . $this->keyField . '}\" data-id=\"$child->' . $this->keyField . '\" class=\"class-$child->class"' .
|
$eval = '"<li id=\"selector-' . $this->getName() . '-{$child->' . $this->keyField . '}\" data-id=\"$child->' . $this->keyField . '\" class=\"class-$child->class"' .
|
||||||
' . $child->markingClasses() . "\"><a rel=\"$child->ID\">" . $child->' . $this->labelField . ' . "</a>"';
|
' . $child->markingClasses() . "\"><a rel=\"$child->ID\">" . $child->' . $this->labelField . ' . "</a>"';
|
||||||
|
|
||||||
if($isSubTree) {
|
if($isSubTree) {
|
||||||
return substr(trim($obj->getChildrenAsUL('', $eval, null, true)), 4, -5);
|
return substr(trim($obj->getChildrenAsUL('', $eval, null, true, $this->childrenMethod)), 4, -5);
|
||||||
} else {
|
} else {
|
||||||
return $obj->getChildrenAsUL('class="tree"', $eval, null, true);
|
return $obj->getChildrenAsUL('class="tree"', $eval, null, true, $this->childrenMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user