kartik\tree\TreeView::initTreeView PHP Method

initTreeView() protected method

Initializes and validates the tree view configurations
protected initTreeView ( )
    protected function initTreeView()
    {
        $this->validateSourceData();
        $this->_module = Config::initModule(Module::className());
        $this->initSelectedNode();
        if (empty($this->emptyNodeMsg)) {
            $this->emptyNodeMsg = Yii::t('kvtree', 'No valid tree nodes are available for display. Use toolbar buttons to add tree nodes.');
        }
        $this->_hasBootstrap = $this->showTooltips;
        $this->breadcrumbs += ['depth' => null, 'glue' => ' » ', 'activeCss' => 'kv-crumb-active', 'untitled' => Yii::t('kvtree', 'Untitled')];
    }

Usage Example

 /**
  * @inheritdoc
  */
 protected function initTreeView()
 {
     if (!$this->hasModel() && $this->name === null) {
         throw new InvalidConfigException("Either 'name', or 'model' and 'attribute' properties must be specified.");
     }
     $this->showCheckbox = true;
     $css = 'kv-tree-input-widget';
     if (!$this->showToolbar) {
         $css .= ' kv-tree-nofooter';
     }
     Html::addCssClass($this->treeOptions, $css);
     parent::initTreeView();
     $this->_hasBootstrap = $this->showTooltips || $this->asDropdown;
 }