diff --git a/forms/TreeDropdownField.php b/forms/TreeDropdownField.php index d3a7cbc8c..91200a27a 100644 --- a/forms/TreeDropdownField.php +++ b/forms/TreeDropdownField.php @@ -50,6 +50,13 @@ class TreeDropdownField extends FormField { 'tree' ); + /** + * @config + * @var int + * @see {@link Hierarchy::$node_threshold_total}. + */ + private static $node_threshold_total = 30; + /** * @ignore */ @@ -303,7 +310,8 @@ class TreeDropdownField extends FormField { if ($this->filterCallback || $this->search != "" ) $obj->setMarkingFilterFunction(array($this, "filterMarking")); - $obj->markPartialTree($nodeCountThreshold = 30, $context = null, + $nodeCountThreshold = Config::inst()->get('TreeDropdownField', 'node_threshold_total'); + $obj->markPartialTree($nodeCountThreshold, $context = null, $this->childrenMethod, $this->numChildrenMethod); // allow to pass values to be selected within the ajax request diff --git a/model/Hierarchy.php b/model/Hierarchy.php index c42b94be5..7c8b71bd5 100644 --- a/model/Hierarchy.php +++ b/model/Hierarchy.php @@ -218,10 +218,12 @@ class Hierarchy extends DataExtension { * @param int $nodeCountThreshold See {@link getChildrenAsUL()} * @return int The actual number of nodes marked. */ - public function markPartialTree($nodeCountThreshold = 30, $context = null, + public function markPartialTree($nodeCountThreshold = null, $context = null, $childrenMethod = "AllChildrenIncludingDeleted", $numChildrenMethod = "numChildren") { - if(!is_numeric($nodeCountThreshold)) $nodeCountThreshold = 30; + if(!is_numeric($nodeCountThreshold)) { + $nodeCountThreshold = Config::inst()->get('Hierarchy', 'node_threshold_total'); + } $this->markedNodes = array($this->owner->ID => $this->owner); $this->owner->markUnexpanded();