From: avl Date: Wed, 27 Jan 2010 12:49:51 +0000 (+0200) Subject: customize get levels X-Git-Tag: 0.5~366 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=0633e5bcf5de333e183475d35fc47a15a2503cf7;p=ipf.git customize get levels --- 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){