]> git.andy128k.dev Git - ipf.git/commitdiff
customize get levels
authoravl <alex.litovchenko@gmail.com>
Wed, 27 Jan 2010 12:49:51 +0000 (14:49 +0200)
committeravl <alex.litovchenko@gmail.com>
Wed, 27 Jan 2010 12:49:51 +0000 (14:49 +0200)
ipf/form/field/treemodelchoice.php

index a2818d33aadaa5b9b8d8af6dfbc974f65aca97f0..caedaeb5bce9a35ce865f04f90f5668a58551b36 100644 (file)
@@ -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){