From 0633e5bcf5de333e183475d35fc47a15a2503cf7 Mon Sep 17 00:00:00 2001 From: avl Date: Wed, 27 Jan 2010 14:49:51 +0200 Subject: [PATCH] customize get levels --- ipf/form/field/treemodelchoice.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ipf/form/field/treemodelchoice.php b/ipf/form/field/treemodelchoice.php index a2818d3..caedaeb 100644 --- a/ipf/form/field/treemodelchoice.php +++ b/ipf/form/field/treemodelchoice.php @@ -9,15 +9,19 @@ class IPF_Form_Field_TreeModelChoice extends IPF_Form_Field_Choice{ parent::__construct($params); $this->_models = $params['models']; $choices = array('--------'=>''); + $this->_collectTreeRecursive(&$choices); + $this->setChoices($choices); + $this->widget->setLevels($this->_getLevels()); + } + + protected function _getLevels(){ $levels = array(); foreach($this->_models as &$m){ $m['objects'] = IPF_ORM_Query::create()->from($m['model'])->orderby('ord')->execute(); $levels[] = $m['field']; } - $this->_collectTreeRecursive(&$choices); - $this->setChoices($choices); - $this->widget->setLevels($levels); - } + return $levels; + } protected function _collectTreeRecursive(&$choices,$level=0,$parent_id=null,$valname=''){ foreach($this->_models[$level]['objects'] as $o){ -- 2.49.0